passing data using multiple form styles

Discussion in 'JavaScript' started by lz300, Feb 16, 2007.

  1. #1
    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 (or within the same form) that uses radio buttons, and have its value pass along with the list value. 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 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="First Video"> Video One </option>
    <option value="Second Video"> Video Two </option>
    <option value="Third Video"> 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>
     
    lz300, Feb 16, 2007 IP
  2. Logic Ali

    Logic Ali Well-Known Member

    Messages:
    170
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    108
    #2
    Change the appropriate line to this:
     var page2 = "receiver.html?" + URL+'&vidsize='+form.vidsize[form.vidsize[0].checked?0:1].value;
    
    Code (markup):
    In both radio button tags insert:
    onclick='if(site.selectedIndex>0)alpha(this.form)'
    Code (markup):
     
    Logic Ali, Feb 18, 2007 IP
  3. lz300

    lz300 Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thank you!

    That is exactly what I was looking for.

    If anyone is interested, here is the link to what this is for:

    http://members.cox.net/lz300a/jukebox/frame_launcher.html
     
    lz300, Feb 18, 2007 IP