Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 7 of 7
  1. #1
    Member webmastercorey's Avatar
    Join Date
    Nov 2005
    Location
    Kansas
    Posts
    49
    Member #
    11909
    I need something like this:

    HTML Code:
    <input type="radio" name="item_number" id="23.00"  value="001" onClick="change('amount')" />$23.00 USD (Individual)<br />
    <input type="radio" name="item_number" id="156.00"  value="002" onClick="change('amount')" />1/4 Case (12 Trucks) $156.00<br />
    <input type="radio" name="item_number" id="312.00" value="003" onClick="change('amount')" />1/2 Case (24 Trucks) $312.00<br />
    <input type="radio" name="item_number" id="624.00" value="004" onClick="change('amount')" />1 Case (48 Trucks) $624.00<br />
    to change the value of this:
    HTML Code:
    <input type="hidden" name="amount" value="23.00" />
    To whatever the id is for the radio buttons are. (ex. id="312.00" so <input type="hidden" name="amount" value="312.00" />) Or somehow in some way make it when they select an option that it changes the value of the AMOUNT input to those values.

    Any idea? I've been stumped for 5 hours... my head hurts.
    "What good will it be for a man if he gains the whole world, yet forfeits his soul?"
    -Matthew 16:26

  2.  

  3. #2
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    First of all, this'll be better handled by an unobtrusive script. However, if you do it this way, make the first parameter you're passing to change `event'. And probably drop the `amount' parameter. Give the hidden input an id. Then, your change function:

    Code:
    function change(evt)
    {
        if (evt.srcElement)
            evt.target = evt.srcElement; // disambiguate target
    
        document.getElementById('amount').value = evt.target.id;
    }
    This is assuming you gave your hidden field an id of `amount'. The if statement at the beginning disambiguates between the normal target property and IE's usage of srcElement for the same thing.

  4. #3
    Member webmastercorey's Avatar
    Join Date
    Nov 2005
    Location
    Kansas
    Posts
    49
    Member #
    11909
    I ended up using a onclick="changeValue1()" method similar to yours.

    that would change the value of an id

    Code:
    function changeValue1(){
          document.getElementById('amount').value = '23.00';
          document.getElementById('item_name').value = 'Individual 7.625 inch Herron Trucks';
          }
    I'm not so experienced in Javscript, but seems to work fine.
    "What good will it be for a man if he gains the whole world, yet forfeits his soul?"
    -Matthew 16:26

  5. #4
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    Well, in that context, you would have been better served by doing a call to a single changeValue method and passing it the amount and item name right there.

  6. #5
    Senior Member Steax's Avatar
    Join Date
    Dec 2006
    Location
    Bandung, Indonesia
    Posts
    1,207
    Member #
    14572
    May I ask why you're doing this? It's a lot easier to do a switch detection via your server-side language. The problem is, if JS is turned off, your form will malfunction...
    Note on code: If I give code, please note that it is simply sample code to demonstrate an effect. It is not meant to be used as-is; that is the programmer's job. I am not responsible to give you support or be held liable for anything that happens when using my code.

  7. #6
    Senior Member seanmiller's Avatar
    Join Date
    Sep 2003
    Location
    Glastonbury, UK
    Posts
    868
    Member #
    3263
    Liked
    1 times
    So what you're actually trying to do is pass the code, description and value to the script?

    I think you've overcomplicated the whole thing and, as Steax points out, have created a reliance on Javascript being enabled that is unnecessary.

    This is how I'd do it...

    Code:
    <input type="radio" name="item" value="001:23.00:Individual Widget" />Individual $23.00<br />
    <input type="radio" name="item" value="002:200.00:12 Widgets in a little box" />1/4 Case (12 Trucks) $200.00<br />
    <input type="radio" name="item" value="003:350.00:24 Widgets in a bigger box" />1/2 Case (24 Trucks) $350.00<br />
    <input type="radio" name="item" value="004:624.00:48 Widgets in a huge box" />1 Case (48 Trucks) $624.00<br />
    Code:
    $item = explode(":",$_POST['item']);
    $item_number = $item[0];
    $item_cost = $item[1];
    $item_description = $item[2];
    Sean

  8. #7
    Member webmastercorey's Avatar
    Join Date
    Nov 2005
    Location
    Kansas
    Posts
    49
    Member #
    11909
    Here is the page my script is on: http://www.herrontrucks.com/order.php

    The reason I have to do this is because PayPal is only letting one amount to be submitted on a page. And I want the option to have different amounts to be submitted. I'm not wanting to do a shopping cart though because it really is the same item, just different ways to purchase it.
    "What good will it be for a man if he gains the whole world, yet forfeits his soul?"
    -Matthew 16:26


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 05:46 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com