General Computing and Internet This is a discussion on, passing a variable to input type within the Community Forums forum; I want to pass the value of a drop down list to a hidden Input in my html code, something ...

Reply
 
LinkBack Thread Tools
Old 03-09-2004, 06:29 PM   #1
Tiscali User Member
 
petevick's Avatar
 
Join Date: Mar 2004
Location: Ibstock
Posts: 233
Thanks: 0
Thanked 0 Times in 0 Posts
passing a variable to input type

I want to pass the value of a drop down list to a hidden Input in my html code, something like...


Code:
<input type="hidden" name="quantity" value= list.value>
Any one got any ideas on how this might be achieved. I've had several goes, but all have failed
__________________
Pete Vickerstaff
Freedom2Surf Pure Crap 512k/50:1 GW5
petevick is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 04-09-2004, 08:16 AM   #2
Tiscali User Member
 
petevick's Avatar
 
Join Date: Mar 2004
Location: Ibstock
Posts: 233
Thanks: 0
Thanked 0 Times in 0 Posts
found the answer

so here it is....

bit of java first...
Code:
<script language="JavaScript"> 
function setValue()
{
var form=window.document.steel;
var select=form.steel_seats;
form.quantity.value=select[select.selectedIndex].value;
}
</script>
then the form itself....

Code:
      <form target="paypal" name="steel" action="https://www.paypal.com/cgi-bin/webscr" method="post" onSubmit="setValue()">
        <p align="left"><select size="1" name="steel_seats">
        <option value="1">1</option>
        <option value="2">2</option>
        <option value="3">3</option>
        <option>4</option>
        <option value="5">5</option>
        </select>
        <input type="image" src="https://www.paypal.com/en_GB/i/btn/x-click-but22.gif" border="0" name="I4" alt="Make payments with PayPal - it's fast, free and secure!" width="94" height="21"></p>
        <input type="hidden" name="add" value="1">
        <input type="hidden" name="cmd" value="_cart">
        <input type="hidden" name="quantity">
        <input type="hidden" name="lc" value="GB">
      </form>
the hidden field name "quantity" gets its value when the user clicks to submit, the jave function is run, and the field gets its value.

Thanks to chessbott over at Tek-Tips forums for the answer.
__________________
Pete Vickerstaff
Freedom2Surf Pure Crap 512k/50:1 GW5
petevick is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
change input TYPE="hidden" to input TYPE="text" petevick Webspace & Domain Names 4 19-05-2004 08:36 PM


All times are GMT. The time now is 06:33 AM.