benjam Posted April 19, 2006 Share Posted April 19, 2006 I have a form that POSTs to php, and inside that form I have several inputs for peoples names, i.e. first_name and last_nameThese 8 field groups have the name 'first_name[]' and 'last_name[]' so that when they are passed to the php script I can access them through $first_name[$i] and $last_name[$i].My problem is this, after a certain date, I want to disable those input boxes, but I cannot select them through JavaScript because they have a name that contains square brackets.I have tried:form.first_name[].disabled = true; // errorfor (var i = 0; i < 8; i++){ form.first_name[i].disabled = true; // error}form.first_name.disabled = true; // errorAny suggestions on how to disable these input elements?Thanks. Quote Link to comment Share on other sites More sharing options...
Mattyspatty Posted April 22, 2006 Share Posted April 22, 2006 bump, i would like to know this too! Quote Link to comment Share on other sites More sharing options...
GBS Posted April 22, 2006 Share Posted April 22, 2006 Hi there,Not sure to get all your problem, but maybe this code example could help you,,[code]<html><body><form>Input 1: <input type="text" id="first_name" value="disabled">Input 2: <input type="text" id="last_name" value="enabled">Input 3: <input type="text" id="[other_name]" value="disabled"><br>Cbox1 <u>disabled</u>: <input type="checkbox" id="checkbox[1]" value="disabled">Cbox2 <u>disabled</u>: <input type="checkbox" id="checkbox[2]" value="disabled">Cbox3 enabled: <input type="checkbox" id="checkbox[3]" value="enabled">Cbox4 enabled: <input type="checkbox" id="checkbox[4]" value="enabled"></form><script>document.getElementById('first_name').disabled = true;document.getElementById('last_name').disabled = false;document.getElementById('[other_name]').disabled = true;for (var i = 1; i < 3; i++){eval("document.getElementById('checkbox['+i+']').disabled = true;"); }</script></body></html>[/code]Good luck,,l8tr, Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.