Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - If Yes display text box
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Topic ClosedIf Yes display text box

 Post Reply Post Reply Page  <12
Author
yamushk View Drop Down
Newbie
Newbie


Joined: 02 December 2008
Status: Offline
Points: 4
Direct Link To This Post Posted: 03 December 2008 at 12:52am
("") is that "hiddenBox" and "Select1"?
Back to Top
jamie.townsend View Drop Down
Groupie
Groupie


Joined: 07 December 2007
Location: England
Status: Offline
Points: 114
Direct Link To This Post Posted: 03 December 2008 at 1:42pm
try this:
 

 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled Page</title>
<script language="javascript">
function chkFrm()
{
if (document.getElementById("Select1").value == "Yes")
{
document.getElementById("hiddenBox").style.visibility = "visible";
}
else
{
document.getElementById("hiddenBox").style.visibility = "hidden";
}
if (document.getElementById("Select2").value == "Yes")
{
document.getElementById("hiddenBox2").style.visibility = "visible";
}
else
{
document.getElementById("hiddenBox2").style.visibility = "hidden";
}
}
</script>
</head>
<body>
<form method="post" action="#" name="form1">
Do you like pasta ?
<select id="Select1" onchange="chkFrm()">
<option value="No">No</option>
<option value="Yes">Yes</option>
</select>
<div id="hiddenBox" style="visibility:hidden">
Do you prefer it with or without sauce?  <input id="Text1" type="text" />
</div>
<br /><br />
Are you married ?
<select id="Select2" onchange="chkFrm()">
<option value="No">No</option>
<option value="Yes">Yes</option>
</select>
<div id="hiddenBox2" style="visibility:hidden">
Spouse name?  <input id="Text1" type="text" />
</div>
</form>
</body>
</html>
 
Back to Top
yamushk View Drop Down
Newbie
Newbie


Joined: 02 December 2008
Status: Offline
Points: 4
Direct Link To This Post Posted: 07 December 2008 at 5:11pm
Wow - thanks a lot, Jamie Townsend! I have never gotten such a complete and quick answer on a forum!

Cheers!
Thumbs Up
Back to Top
jamie.townsend View Drop Down
Groupie
Groupie


Joined: 07 December 2007
Location: England
Status: Offline
Points: 114
Direct Link To This Post Posted: 07 December 2008 at 5:27pm
no problems :)
Back to Top
shakir View Drop Down
Groupie
Groupie


Joined: 08 November 2007
Location: Saudi Arabia
Status: Offline
Points: 41
Direct Link To This Post Posted: 31 December 2008 at 2:01pm
open a notepad file and copy past all the script with html code. Then save the file as html save and name. Then double click the file will open in default browser then check it
Back to Top
bf1848 View Drop Down
Newbie
Newbie


Joined: 23 January 2009
Status: Offline
Points: 1
Direct Link To This Post Posted: 23 January 2009 at 7:50pm

how can i modify this code to let the hidden field be a dropdown menu instead of a textbox?

Back to Top
Monie View Drop Down
Newbie
Newbie
Avatar

Joined: 15 January 2008
Location: Borneo
Status: Offline
Points: 7
Direct Link To This Post Posted: 25 January 2009 at 3:33pm
Just change the text input to a drop down menu and give them the same ID!
But just for your info, hiding a text field (without disabling them first) will be submitted together with your form submit process.
Back to Top
 Post Reply Post Reply Page  <12

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.