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 = unescape(data);
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>

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)'

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.