Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

passing text fields to another form ....PLEASE HELP...!! 1

Status
Not open for further replies.

mobsterz

Technical User
Feb 14, 2004
13
0
0
GB
Hi,

I am currently having so many problems with passing text fields to the next page, but I only want the entered fields to be displayed on the next page. So far I have been able to pass 1 text field to another page, in the text box format, but as soon as I try and pass multiple fields, it doesn't seem to work. Here's my code so far:

The first page (form):

<html>
<head>

<title>Pass variables with javascript</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#FFFFFF" text="#000000">
<br>
<br>
<h3><font color="#000066">Pass variables in URL string with javascript:</font></h3>
<br>
<br>
<form method="get" action="nextpage.html">
<p>
<input type="checkbox" name="checkbox1">
<input type="text" name="myvar">
</p>
<p>
<input type="checkbox" name="checkbox2">
<input type="text" name="myvar2">
</p>
<p>
<input type=submit>
</p>
</form>
</body>
</html>


and the next page:

<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#FFFFFF" text="#000000">
<br>
<br>
<h3> variable passed</h3>
<br>
<br>
<script>
twdlength = window.location.search.length
myvar=window.location.search.substring(7,twdlength);
</script>

<form name="whatever">
<input type="text" name="newvar" value="myvar">
</form>
</body>

<script>
document.forms["whatever"].newvar.value = myvar;
</script>
</html>

In the first page, I have changed the form so that it has 2 text fields and 2 checkboxes next to them. The second page works at the moment, but only for 1 input text field. I basically need to carry over and display the text fields that have only been entered into, and leave out the ones that do not have entries.

How can I achieve this? Thank you so much.

 
Could you anyhow use value table. Cause if you just define form elements to the second page, it should work.

document.forms.formname[0]
document.forms.formname[1]
 
Add for previous message: with value table i ment element table
 
try this

Code:
var sSearch = window.location.search.substring(1);
var Parameters = new Object();
var sNameValuePairs = sSearch.split('&');
var sNameValuePair;
for (var i = 0; i < sNameValuePairs.length; i++) {
    sNameValuePair = sNameValuePairs[i].split('=');
    Parameters[sNameValuePair[0]] = sNameValuePair[1];
}

alert(Parameters[="myvar"])
alert(Parameters[="myvar2"])

hth

simon
 
another MS bug !!!

I meant

alert(Parameters["myvar"])
alert(Parameters["myvar2"])

;)
 
Thank you so much for those responses....U guys are the coolest!

I can see how the above code works, but how should I adjust the code so then the variables are passed into text boxes (in the next page)?

Also, would this code be okay for multiple input text boxes?

Thanks again. I really appreciate this invaluable help.[smile]
 


just use

Code:
document.forms("whatever").elements("newvar").value = Parameters["myvar"]

simon
 
WOW !!

I got it working, I have to give it to U, Ur a GENIUS....

God bless you.

One last query.......

Would I have to define the form on the action page, dynamically, in order to only display the text fields that had been entered in to, whilst leaving out, and not displaying any blank boxes for the text fields that had not been entered into (in the previous page)? If this is so, how should I go about doing this?

Thank you so much, take care
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top