0

i am filling this value using javascript code. after that i am able to see this value in cosole. but value not visible in box. due to this i am unable to click submit button.this element is in a form tag.images link https://i.sstatic.net/quZ8f.png https://i.sstatic.net/r9KgX.jpg

function myfn(){
  document.getElementsByName("ELEC_CURR_B_PHASE").value="415V";
  var x= document.getElementsByName("ELEC_CURR_B_PHASE").value="415V";
  console.log(x);

};myfn()

result after running code
inspect element image

1 Answer 1

1

getElementsByName() returns a NodeList and to set the property value, select the first index.

function myfn(){
  document.getElementsByName("ELEC_CURR_B_PHASE").value="415V";
  var x= document.getElementsByName("ELEC_CURR_B_PHASE")[0].value="415V";
  console.log(x);
};
myfn();
Sign up to request clarification or add additional context in comments.

1 Comment

Great! please mark this as the answer so it may help others as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.