Is it possible to put an Array values to a hidden input field?
I am using ASP Classic code with javascript.
I have this asp code that puts every content of an Array to my hidden field.
Dim Data
For Each Data in aRecords(14)
Response.write "<INPUT type='hidden' name='hdn_field' value=""" & Data & """>"
Next
It appears in the view source like this:
<INPUT type='hidden' name='hdn_field' value="arrayvalue1">
<INPUT type='hidden' name='hdn_field' value="arrayvalue2">
But when i try to get the value of the “hdn_field” via javascript code. It doesn’t work.
I call it by doing this (javascript):
testValue = document.frm_MainPage.hdn_field.value
I’m not sure if the mistake is in it’s way of assigning it to hidden field or by the way i call it in javascript.
Please help.
Your help will be greatly appreciated.
Thank you.
Because there are several hidden inputs with the same name, when you get the value of “hdn_field” you get all of those values in one go. To get only one value you need to give each hidden input a unique name.
Try something like this: