SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    ********* Addict jaiem's Avatar
    Join Date
    Dec 2000
    Location
    New York, USA
    Posts
    1,006
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm making an order form and need some help using JavaScript to set the values of some of the tags in the HTML FORM.

    In the order FORM there will be a hidden tag for the price (example: <type=HIDDEN name=PRICE value=123>). For each item there will be a set of radio buttons for certain options. The options are mutually exclusive so radio buttons are used instead of check boxes (i.e. only one option per item).

    Here's what I need:

    Depending on which radio button is CHECKED the value of the PRICE tag in the FORM needs to be changed. IOW, if the customer CHECKS radio button 1 PRICE=whatever1, for radio button 2 PRICE=whatever2, etc etc.

    Any help is appreciated - Thanks!
    Ocean View Host - Affordable web hosting plans for any business.
    Modern Technology, Old Fashioned Value & Service!
    U.S. Merchant Services - Reliable merchant account services for all business!
    Quality People Providing A Quality Service!

  2. #2
    SitePoint Zealot
    Join Date
    Dec 1999
    Posts
    137
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    First you must create a function like this:

    <script>
    function changevalue(newvalue){
    document.form1.price.value = newvalue;
    }
    </script>

    And your form should be like this:

    <form name="form1" action=something.ext">
    <input type="hidden" name="price" value="123">
    <input type="radio" name="option" value="456" onclick="changevalue(this.value)">Option1
    <input type="radio" name="option" value="789" onclick="changevalue(this.value)">Option2
    </form>

  3. #3
    ********* Addict jaiem's Avatar
    Join Date
    Dec 2000
    Location
    New York, USA
    Posts
    1,006
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PGA,

    Why not just do:

    <form name="form1" action=something.ext">
    <input type="hidden" name="price" value="123">
    <input type="radio" name="option" value="456"
    language="JavaScript" onclick="document.form1.price.value = 456;">Option1
    <input type="radio" name="option" value="789"
    language="JavaScript" onclick="document.form1.price.value = 789;">Option2
    </form>


    ???????????????
    Ocean View Host - Affordable web hosting plans for any business.
    Modern Technology, Old Fashioned Value & Service!
    U.S. Merchant Services - Reliable merchant account services for all business!
    Quality People Providing A Quality Service!

  4. #4
    SitePoint Zealot
    Join Date
    Dec 1999
    Posts
    137
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's the same. I just use functions since that way my html is more organized and also I have to type less (this is not the case cuz we only have two radio inputs).
    Besides, less code means pages loading faster.
    Last edited by PGA; Mar 6, 2001 at 10:05.

  5. #5
    ********* Addict jaiem's Avatar
    Join Date
    Dec 2000
    Location
    New York, USA
    Posts
    1,006
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Gotcha.

    Thanks!
    Ocean View Host - Affordable web hosting plans for any business.
    Modern Technology, Old Fashioned Value & Service!
    U.S. Merchant Services - Reliable merchant account services for all business!
    Quality People Providing A Quality Service!


Bookmarks

Posting Permissions

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