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 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Dec 2005
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Combo box selection setting several hidden form values

    I posted this in the javascript forum thinking that the solution would most likely involve it. But as I thought that since it that my post seems to have mustarded little interest there, I would post here as well. Any thoughts would be welcomed.

    I would like to be able to select a value (product) from a combo list and then have that selection dictate the value of several different hidden input variables in a form when submitted. I am interfacing with a third party payment processor and the data necessary to process the payment must be assigned to its predefined variables. For example, a user would see and be able to select one of the following:

    Combo List \/
    ------------------
    -Small Bracket
    -Large Bracket


    But when the selection is made I need to be able set values like these in my form when I click Submit (Buy Now):

    <input type=’hidden’ name=’product_description’ value=[Set This Value]
    <input type=’hidden’ name=’product_cost’ value=[Set This Amount]
    <input type=’hidden’ name=’product_shipping’ value=[Set This Amount]

    I feel like this should be a simple request but every tutorial I find comes close to telling me what I need but is just not quite enough. I used to program a lot but it has been a few years since I done much. I am new to javascript but comfortable with programming logic. Any help anyone can provide would be greatly appreciated.

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    So because you were impatient, you went and disregarded the forum rules about cross posting. Please be patient in the future. You aren't the only person asking help on the forums. There is only so much we can do. Threads slip by sometimes with out ever being answered.
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Untitled Document</title>
    <script type="text/javascript">
    function changeValue(obj){
    	if(obj.value=="sbracket"){
    		document.forms[0].product_description.value="sbracket";
    		document.forms[0].product_cost.value="10.99";
    		document.forms[0].product_shipping.value="standard";
    	}
    	else if(obj.value=="lbracket"){
    		document.forms[0].product_description.value="lbracket";
    		document.forms[0].product_cost.value="14.99";
    		document.forms[0].product_shipping.value="nextday";
    	}
    	alert(document.forms[0].product_description.value)//you can remove this
    	alert(document.forms[0].product_cost.value)//you can remove this
    	alert(document.forms[0].product_shipping.value);//you can remove this
    }
    </script>
    </head>
    
    <body>
    <form action="#" method="post">
    <select name="item" onchange="changeValue(this)">
    <option value="sbracket">Small Bracket</option>
    <option value="lbracket">Large Bracket</option>
    </select>
    <input type="hidden" name="product_description" value="" />
    <input type="hidden" name="product_cost" value="" />
    <input type="hidden" name="product_shipping" value="" />
    </form>
    </body>
    </html>

  • #3
    New to the CF scene
    Join Date
    Dec 2005
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    My sincerest apologies, I meant no disrespect to this forum or its users. I highly value both the information and effort that is found here. I only posted in this tread in addition to the javascript thread because I was unsure if I had posted in the correct one to begin with. Your input is greatly appreciated, I thank you for your time, and again, I meant no disrespect.

  • #4
    New to the CF scene
    Join Date
    Dec 2005
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Posting additional questions in correct javascript thead posting here: http://www.codingforums.com/showthread.php?t=73774
    Last edited by Pytec; 12-01-2005 at 06:46 AM.


  •  

    Posting Permissions

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