/    Sign up×
Community /Pin to ProfileBookmark

Smart HTML Forms

HTML Form Script

I need to write a script that will allow managers to be able to select diferent parts of a form via tick boxes and those relevent parts of the form will appear ie

A new user requires NT and Email but not novell ….. so they would tick NT and Email and the relevent parts of the form appear , but if they untickthe checkbox the NT part of the form would disappear .

I have written a demo script but it uses <DIV> and each part of the form jups down the page because I am using the <hidden> command could anyone point me in the correct direction

Demo
<HTML>
<HEAD>
<META NAME=”GENERATOR” Content=”Microsoft Visual Studio 6.0″>
<TITLE></TITLE>
<SCRIPT LANGUAGE=javascript>
<!–
function hideText(){
if(document.forms[0].checkbox1.checked){
document.getElementById(“formitem”).style.visibility=”hidden”
}else{
document.getElementById(“formitem”).style.visibility=”visible”

}
}

//–>
</SCRIPT>
<SCRIPT LANGUAGE=javascript>
<!–
function hideText2(){
if(document.forms[0].checkbox2.checked){
document.getElementById(“formitem2″).style.visibility=”hidden”
}else{
document.getElementById(“formitem2″).style.visibility=”visible”

}
}

//–>
</SCRIPT>
</div>
</HEAD>
<BODY>

<FORM action=”” method=POST name=form >
NT 1<INPUT type=”checkbox” name=checkbox1 onmousedown=”javascript:hideText()”><p>
Email- 2<INPUT type=”checkbox” name=checkbox2 onmousedown=”javascript:hideText2()”><p>
<div id=”formitem” style=”visibility:hidden;Position:relative”><td><tr>Test 1<INPUT type=”text” name=text1>
<div id=”formitem2″ style=”visibility:hidden ;Position:relative”><blink>Test 2</blink><INPUT type=”text” name=text2 >

</div>
</FORM>
</BODY>
</HTML>

Cheers
Andy

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @sismeya spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...