...

View Full Version : passing data using multiple form styles



lz300
02-03-2007, 07:59 AM
I have a page in which I successfully pass code from a list form to another page via a query string. I now wish to add an additional form that uses radio buttons, and passes that value in the query string, as well. The problem I have is capturing the value of the radio button selection into a variable that can be added to the query string.

- The radio button will default to one choice, and if not changed, I wish it to pass the default value.

- I don't know if it is possible...I would like the code to pass when a list item is selected, OR if a list item is already selected and then the radio button is changed. If this is not possible, then I would be happy with just the list item triggering the new page. I want to do this without the use of a SUBMIT button.

Any ideas on this?

Here is my code:

Sender.html
<html>
<head>
<title>Sender</title>
<script>
function alpha(form)
{
var URL = form.site.options[form.site.selectedIndex].value;
if (URL == "void")
window.parent.self.status="Please choose a video";
else
{
var page2 = "receiver.html?" + URL;
window.location = page2;
}
}
</script>
</head>
<body>
<form>
Select the size:
<INPUT TYPE="RADIO" NAME="vidsize" VALUE="sm"> Small
<INPUT TYPE="RADIO" NAME="vidsize" VALUE="lg" CHECKED> Large
</form>
<form name=beta>
<select name=site SIZE=6 onChange="alpha(this.form)">
<option selected value="void"> Choose a video... </option>
<option value="1122511277,ms"> Video One </option>
<option value="1482167041,ms"> Video Two </option>
<option value="9336611397,ms"> Video Three </option>
</select>
</form>
</body>
</html>

receiver.html
<html>
<head><title>Receiver</title></head>
<body>
<script>
var query = window.location.search;
// SkipS the leading ?
if (query.substring(0, 1) == '?')
query = query.substring(1);
var data = query.split(',');
for (i = 0; (i < data.length); i++)
data[i] = unescape(data[i]);
document.write("data[0] = " + data[0] + "<br>");
document.write("data[1] = " + data[1] + "<br>");
document.write("data[2] = " + data[2] + "<br>");
document.write("data[3] = " + data[3] + "<br>");
</script>
</body>
</html>

FJbrian
02-04-2007, 08:09 PM
void might be a reserved word, not sure just sorta rings a bell.

your radio buttons are outside the form
paste that under the form tag and/or give it it's own form tags

lz300
02-04-2007, 10:04 PM
I put the radio buttons under the existing form tags, but I still don't have a way of passing both variables to my function.

I changed my onChange line to the following:

<select name=site SIZE=6 onChange="alpha(this.form,this.vidSize)">

and my function line to the following:

function alpha(form,vidSize)

but I get 'undefined' for the value of vidSize, instead of 'lg' or 'sm'

FJbrian
02-04-2007, 10:43 PM
you have a comma after form not a period
it shoud be the name of the form not form so "beta"

lz300
02-05-2007, 12:33 AM
You lost me.

If I replace the commas after 'form' with periods, I get 'Expected Identifier' errors.

Also, where do I replace the word 'form' with the word 'beta' ?

FJbrian
02-05-2007, 05:43 AM
You lost me.

If I replace the commas after 'form' with periods, I get 'Expected Identifier' errors.

Also, where do I replace the word 'form' with the word 'beta' ?

skip comma/period, sorry I goofed there. I see you're using that to carry the variable value, sorry.

you named the second form, form name=beta, the first one has no name.

In the first form I believe you're missing a button, submit, or select to "send" the item thru

FJbrian
02-05-2007, 05:47 AM
here
http://www.htmlgoodies.com/tutorials/forms/article.php/3479151

lz300
02-14-2007, 12:54 AM
I'm still having no luck.

I don't want a separate submit option for the radio buttons, I want them to pass with the list value when a list item is clicked on.

I moved the radio buttons into the same form as the list, but am still unable to capture the value of the radio button.

<form name=beta>
Select the size:
<INPUT TYPE="RADIO" NAME="vidsize" VALUE="sm"> Small
<INPUT TYPE="RADIO" NAME="vidsize" VALUE="lg" CHECKED> Large
<select name=site SIZE=6 onChange="alpha(this.form)">
<option selected value="void"> Choose a video... </option>
<option value="1122511277,ms"> Video One </option>
<option value="1482167041,ms"> Video Two </option>
<option value="9336611397,ms"> Video Three </option>
</select>
</form>

lz300
02-19-2007, 04:50 AM
I found the solution in another forum.

Here it is, if anyone is interested:

Change the page2 variable
from: var page2 = "receiver.html?" + URL;

to: var page2 = "receiver.html?" + URL+'&vidsize='+form.vidsize[form.vidsize[0].checked?0:1].value;


In both radio button tags insert:
onclick='if(site.selectedIndex>0)alpha(this.form)'

FJbrian
02-19-2007, 09:55 AM
lz300,
I completely forgot about this. Sorry I didn't get back to you. Please feel free to PM me in the future if ya see I didn't reply to a Q. This one must have slipped thru the cracks, sorry bout that



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum