1,105,534 Community Members

How to add sections to a form

Member Avatar
yankeefan24
Light Poster
36 posts since Mar 2013
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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?

Thanks

Member Avatar
ryantroop
Posting Whiz
321 posts since Jun 2012
Reputation Points: 63 [?]
Q&As Helped to Solve: 50 [?]
Skill Endorsements: 3 [?]
 
0
 

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

So..

<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">
</form>

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

<script>

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

</script>

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!

Ryan

Question Answered as of 9 Months Ago by ryantroop
Member Avatar
yankeefan24
Light Poster
36 posts since Mar 2013
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Thanks

You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: