passing values source




JavaScript Source Code 3000: Forms: Passing Values






































Passing Values (Source)







Here is a clever way of 'unwrapping' the contents of a form when passed from one page to the next. This capability would be useful in many situations, such as passing the contents of a form to another page, retaining information about the current page for the rest of their visit, etc. Great!














JavaScript Source Code 3000: Forms: Passing Values (Source)
Simply click inside the window below, use your cursor to highlight the script, and copy (type Control-c or Apple-c) the script into a new file in your text editor (such as Note Pad or Simple Text) and save (Control-s or Apple-s). The script is yours!!!





    





<!-- THREE STEPS TO INSTALL PASSING VALUES:

1. Copy the form code into the first page with the form
2. Paste the HEAD code into the second HTML page
3. Add the final code into the BODY of your second page -->

<!-- STEP ONE: Paste this code into the HEAD of your HTML document -->

<BODY>

<center>
<form type=get action="passing-values-source.html">
<table border=1>
<tr>
<td>First Name:</td>
<td><input type=text name=firstname size=10></td>
</tr>
<tr>
<td>Last Name:</td>
<td><input type=text name=lastname size=10></td>
</tr>
<tr>
<td>Age:</td>
<td><input type=text name=age size=3></td>
</tr>
<tr>
<td colspan=2><input type=submit value="Submit!">
</td>
</tr>
</table>
</form>
</center>

<!-- STEP TWO: Paste this code into the HEAD of your second document -->

<HEAD>

<SCRIPT LANGUAGE="JavaScript">

<! >
<! >

<!-- Begin
function getParams() {
var idx = document.URL.indexOf('?');
var params = new Array();
if (idx != -1) {
var pairs = document.URL.substring(idx+1, document.URL.length).split('&');
for (var i=0; i<pairs.length; i++) {
nameVal = pairs[i].split('=');
params[nameVal[0]] = nameVal[1];
}
}
return params;
}
params = getParams();
// End -->
</script>
</HEAD>

<!-- STEP THREE: Put this on the page that should read the values -->

<BODY>

<SCRIPT LANGUAGE="JavaScript">

<!-- Begin
firstname = unescape(params["firstname"]);
lastname = unescape(params["lastname"]);
age = unescape(params["age"]);

document.write("firstname = " + firstname + "<br>");
document.write("lastname = " + lastname + "<br>");
document.write("age = " + age + "<br>");
// End -->
</script>



<!-- Script Size: 1.23 KB -->













Wyszukiwarka

Podobne podstrony:
passing values
passing values
source30
Matrix3?pp source
Thread?pp source
arm biquad ?scade ?1 ?st q31? source
arm conv ?2? source
arm mat mult q15? source
Resource 8inl source
arm fir lattice init q31? source
arm fir ?cimate ?st q15? source
constant values
source11
arm correlate ?st q15? source
connector?s source
source8

więcej podobnych podstron