Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    New to the CF scene
    Join Date
    Feb 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    passing data using multiple form styles

    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>

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    Adirondacks
    Posts
    516
    Thanks
    4
    Thanked 4 Times in 4 Posts
    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

  • #3
    New to the CF scene
    Join Date
    Feb 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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'

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Location
    Adirondacks
    Posts
    516
    Thanks
    4
    Thanked 4 Times in 4 Posts
    you have a comma after form not a period
    it shoud be the name of the form not form so "beta"

  • #5
    New to the CF scene
    Join Date
    Feb 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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' ?

  • #6
    Regular Coder
    Join Date
    Jun 2002
    Location
    Adirondacks
    Posts
    516
    Thanks
    4
    Thanked 4 Times in 4 Posts
    Quote Originally Posted by lz300 View Post
    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

  • #7
    Regular Coder
    Join Date
    Jun 2002
    Location
    Adirondacks
    Posts
    516
    Thanks
    4
    Thanked 4 Times in 4 Posts

  • #8
    New to the CF scene
    Join Date
    Feb 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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>

  • #9
    New to the CF scene
    Join Date
    Feb 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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)'

  • #10
    Regular Coder
    Join Date
    Jun 2002
    Location
    Adirondacks
    Posts
    516
    Thanks
    4
    Thanked 4 Times in 4 Posts
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •