Start New Discussion within our Web Development Community

Im working on a form that I need to break in sections. example form.cfm?section=A, form.cfm?section=B and form.cfm?section=C. When employee access form.cfm?section=A, form.cfm?section=B and C need to be disable only section A will available for user to add input. when section B is accessed by supervisor section A and C are disable and when section C is accessed by VP both A and B are disabled. Is there a way to do this with a JavaScrip function?


if an input field is flagged disabled it will not post in a form submission.


<form method="post" action="whatever.cfm">
<input name="a" type="text" />
<input name="b" type="text" disabled="disabled" />
<input name="c" type="text" disabled="disabled" />
<input type="submit" value="submit">

in javascript you can add or remove the attribute like so:


    var oFormElemb = document.forms[0].b.removeAttribute("disabled"); //enable element
    var oFormElema = document.forms[0].a.setAttribute("disabled", "disabled"); //disable element


the reason you need "disabled" to equald "disabled" is that in HTML all that is required is the word,
i.e. <input name="a" type="text" disabled /> however, in XHTML (and to make IE happy) you need it to equal something, therefore the standard is to make it equal disabled.

Hope that helps!


This question has already been answered. Start a new discussion instead.