I am making a form to a string and so, using 2 arrays, I pass the required variables through to a function on the submit button being pressed (the name of the form element and the variable name).
But I’m using eval(), which isn’t good, but I’m not good enough at objects or arrays to fix it.
My real question (although any insight is appreciated) is this: when a text box that corresponds to a radio button is checked, how do I get it to refer to the array and change the variable that gets changed from the array?
For example, if I have an array:
var examplearray =
[
"foo"
]
And onblur of the textbox =
maritalvar = document.getElementById('othermaritaltxt').value
How do I change maritalvar to be foo?
If possible could it search for fo to get foo so that it doesn’t break if I add an element before it (assuming the use of examplearray[0])?
Don’t use dynamic variables, use properties in an object.
Example:
Now the
formDataobject has three properties, just as if you did: