Sending a radio button choice to an html page

Discussion in 'JavaScript' started by Jen-, Sep 29, 2006.

  1. #1
    Hi, is there anyway to send a selected radio button field to an html page using javascript? Thank you!
     
    Jen-, Sep 29, 2006 IP
  2. penagate

    penagate Guest

    Messages:
    277
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hi!

    Please explain a little more in detail what you mean. I am not sure what you are after.

    Regards
    - P
     
    penagate, Sep 30, 2006 IP
  3. Jen-

    Jen- Peon

    Messages:
    151
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Sure, I have a few radio buttons, lets say one is for oranges and another is for tomatoes. Someone selects one of the options, they hit "send or submit." They are taken to one of my web pages for whichever option they picked. The web page that features oranges or the one that features tomatoes.

    I need some javascript that will do that please, thank you.
     
    Jen-, Sep 30, 2006 IP
  4. penagate

    penagate Guest

    Messages:
    277
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Hi,

    You can alter the action attribute of the form, something like this:
    var tomato = document.getElementById('opt-tomato');
    addEHandler(tomato, 'click', function() {
      var parent;
      while (parent.nodeName.toLower() != 'form')
        parent = tomato.parentElement;
      parent.setAttribute('target', 'tomatoes.html');
    });
    
    Code (markup):
    Grab my event listeners code from here:
    http://dev.penagate.com/js/event-listeners.js

    Bear in mind this is not an accessible solution in that it relies on JS support so you would be better served just using links to the pages.

    Regards
    - P
     
    penagate, Sep 30, 2006 IP