0

I am trying to get the value of a field on a form when I call the update function.

   function update(gId, name, status){
      alert(gId);
      alert(name);
      alert(status); \\Works fine and displays the proper element name.
      alert(document.Form.status.value);\\Try to get the value of that element and it returns undefined.
    }

The gId, name and status are all Strings of elements Id's being passed into the update function. I have 3 dynamically created input fields that get updated. Ex: i_name, i_status, i_gid where i can be 0 or more. So when I call this update Im really passing in a string like 0_gid, 0_name, 0_status or 999_gId, 999_name, 999_status..ect.

pseudo form code.

<form>
input id&name=3_gId
input id&name=3_name
input id&name=3_status
Update(3_gId, 3_name, 3_status)
input id&name=11_gId
input id&name=11_name
input id&name=11_status
Update(11_gId, 11_name, 11_status)
</form>

Thanks for any help.

1 Answer 1

1

Try just doing...

var text = document.getElementById(status).value;
alert(text);

or just put the document.getElementById(status).value in the alert

Sign up to request clarification or add additional context in comments.

3 Comments

FML I did that at first and it didnt work I must have had a typo :(.
@user1857654 Okay let me know if it works and accept the answer if it does
I did I was on a 5 Min timer. Thanks for the quick reply +1

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.