...

View Full Version : Link the page together..



luvgal
01-31-2007, 02:44 PM
hi
im wondering how i can do this? when i clicked on the selected checkboxes and press submit button then the subcategory of a checked checkbox is output on the next html page. basically i have set the 2nd html page to be hidden first.. so that the not selected checkbox on the previous page that is not clicked will not show up.. can u please help me out with the javascript on how to link this two pages together? thanks..

this is just an example of what i wanna do:
the first html:

<html>
<form id="FClass" name="FClass" method="get" action="testing2.html">
<body>
<input type="checkbox" name="132" "/>
<strong> 132</strong></p>
<p>
<input type="checkbox" id='138' name="checkbox" />
<strong>138</strong></p>
<p>
<input type="checkbox" id='139' name="checkbox" />
<strong>139</strong></p>
<p><strong>
<input type="submit" name="Submit" value="Submit">
</body>
</form>
</html>

the 2nd html:
<div id="132" style="display:none;">
<p>
<strong> 132</strong></p>
<blockquote>
<p align="left"> <em><strong>No:</strong></em>
<select name="132" id='132'>
<option value="0">0</opton>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
</p>
</blockquote>
</div>


<div id='138' style="display:none;">
<p>
<strong>138 </strong></p>
<blockquote>
<p><em><strong>No:</strong></em>
<select name="138" id="138">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
</select>
</p>
</blockquote>
<p>
</div>

<div id="139" style="display:none;">
<strong>138</strong></p>
<blockquote>
<p><em><strong>No:</strong></em>
<select name="139" size="1" id="139">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
</p>
</blockquote>
</div>
<input type="submit" name="Submit" value="Submit">
</form>
</body>
</html>

miranda
01-31-2007, 03:22 PM
Why send the user to another page? why not hide this info on the 1st page and save the trip to the server? then when the user checks one of the boxes you can display what you want to display

luvgal
01-31-2007, 03:38 PM
well cause i wan the user to select the choices.. and there'll be many button clicks on the same page if i hide the fields when the checkbox is checked. :)

miranda
01-31-2007, 04:07 PM
ok well to get the value using javascript, sent from a form with the method get to another page you need to parse the querystring.

Because you are using checkboxes the user will be able to select all 3 of the checkboxes versus using a radiobutton where the user can only select one of the group. Since the first checkbox has the name 132 and the next two have the name checkbox if you check each of them then click submit, your querystring will look like this
testing2.html?132=on&checkbox=on&checkbox=on&Submit=Submit


to get the value out of the querystring you will first need to read the querystring into a variable

var myUrl = window.location;

since window.location is an object you now need to use the toString() method to make it into a string
var text = myUrl.toString();

Now you can parse the string and look for the instances of the = sign
theStr.indexOf("=");

put together your code will look something like this




var myUrl = window.location;
var text = myUrl.toString();
function get132(theStr){
i = theStr.indexOf("=");
j = theStr.indexOf("&checkbox");
return(theStr.substring(i+1,j));
}

document.write("132 = "+get132(text)+"<br>");



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum