You need to sign in to do that
Don't have an account?
Javascript. Value property return undefined
Hello,
I'm trying to use JS in visualforce page. The target is when the user input data in specific field - to update this value in input field in a list.
the problem: the value property (from the list) return 'undefied'.
However, if I try to get the InnerHTML and print it I get:
<input id="docPage:frm:results:Data:0:j_id39" maxlength="30" name="docPage:frm:results:Data:0:j_id39" size="20" value="1" type="text">
so I assume that I refering to the field correctly.
Any idea how to solve it?
by the way, if I'll update the InnerHTML property than the problem is that field became from InputText to OutputText.
<script type="text/javascript"> function updateAll() { //Input value from User var userInput= document.getElementById('{!$Component.frm.mainblock.massFields.inputSection.inputID}').value; //list Size var listSize = {!blLst.size}; for (i = 0; i < listSize; i++) { var test = document.getElementById('docPage:frm:results:Data:' + i + ':MTVsID').value; alert(test); //get popup with Undefined } } </script>
This is why you are getting error.
All Answers
This is why you are getting error.
Thanks, You're right.
I was trying to refer to 1 level up. (to the apex:column tag instead of the inputField inside the apex:column).
However, I try now to update the code, but still can't get the value (actually now I cannot get even the innerHTML). I assume it something with syntax.
I update the line inside the loop:
var test = document.getElementById('docPage:frm:results:Data:' + i + ':MTVsID:MTVsIDInput').value
Why dont you check the id of input element by doing a inspect element of the columns.
This will give you an idea about the Ids
Great.
You're right again.
I should refer to it only with the ID of the inputField (not need the apex:column in the chain)
Thanks a lot.
var test = document.getElementById('docPage:frm:results:Data:' + i + ':MTVsIDInput').value;