View Single Post
Old 12-04-2012, 12:44 PM   PM User | #7
janehollin
New to the CF scene

 
Join Date: Nov 2012
Posts: 10
Thanks: 1
Thanked 0 Times in 0 Posts
janehollin is an unknown quantity at this point
Fair enough

I would be interested in seeing how this would be done in ASP ?


But in case anyone else is wondering how they would do this:
Carry a number form one form to another and show/hide divs depending on this number.
Here is one method (there will be others)

This one uses
Java
VB
CSS
HTML

1st create 2 forms (ASPX)
call them Form1 and Form2

Code for form1

Code:
<!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>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title></title>
</head>

<body>

<form runat="server" method="post">
	<asp:DropDownList id="MyListBox" runat="server">
	<asp:listitem></asp:listitem>
	<asp:listitem>1</asp:listitem>
	<asp:listitem>2</asp:listitem>
	<asp:listitem>3</asp:listitem>
	<asp:listitem>4</asp:listitem>
	</asp:DropDownList>
	<br />
	<asp:Button id="btnSubmit" runat="server" postbackurl="form2.aspx" text="Next Form Go" />
</form>

</body>

</html>

Code for form2

Code:
<!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>
<meta content="en-gb" http-equiv="Content-Language" />
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title></title>
<script runat="server" language="VB" type="text/vb"> 
Dim strSomeNumber
Sub Page_Load() 
strSomeNumber = Request.Form("MyListBox")
txtMyNumber.Text = strSomeNumber
End Sub 
</script>
<style type="text/css">
#txtMyNumber {
	display: none;
}
</style>
</head>

<body>

<form id="form1" runat="server">
	<asp:TextBox id="txtMyNumber" runat="server"></asp:TextBox>
	<div id="MyDiv1">
		Div number 1 is showing</div>
	<br />
	<div id="MyDiv2">
		Div number 2 is showing</div>
	<br />
	<div id="MyDiv3">
		Div number 3 is showing</div>
	<br />
	<div id="MyDiv4">
		Div number 4 is showing</div>
	<br />
	<asp:Button id="btnSubmit" runat="server" postbackurl="form1.aspx" text="Go Back" width="78px" />
	<br />
</form>
<script type="text/javascript">
function selectrooms() {
var numdivs = 4;
var num = document.getElementById("txtMyNumber").value;
for (var i =1; i<=numdivs; i++) {
var which = "MyDiv" + i;  
document.getElementById(which).style.display = num>=i? "block" : "none";
}}
window.onload=selectrooms ; 
</script>

</body>

</html>

I hope someone will post a much simpler method of doing this - but until then this should start you along the way.

NOTE - I normally work with MySQL/SQL/VBA etc. I DON'T do websites, but due to cutbacks I am now the firm's webbie
janehollin is offline   Reply With Quote