473,387 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Select box value changes value of hidden field


Hello,

Another newbie here... I've been trying to make this work for days now
and have finally decided to post as I can't seem to get it to work.
Here's what I'm trying to do...

I have a select box with three options and a separate hidden field.
The value of a hidden field is dependent upon which of the three
options is selected. For example, the three select options are 1, 2,
3... if 1 is selected, the value of the hidden field is 9.99, if 2 is
selected the value of the hidden field is 12.99, if 3 is selected, the
value of the hidden field is 15.99.

Thanks in advance for your help!
-Dave

Apr 25 '06 #1
5 2738

dv****@ix.netcom.com wrote:
Hello,

Another newbie here... I've been trying to make this work for days now
and have finally decided to post as I can't seem to get it to work.
Here's what I'm trying to do...

I have a select box with three options and a separate hidden field.
The value of a hidden field is dependent upon which of the three
options is selected. For example, the three select options are 1, 2,
3... if 1 is selected, the value of the hidden field is 9.99, if 2 is
selected the value of the hidden field is 12.99, if 3 is selected, the
value of the hidden field is 15.99.

Thanks in advance for your help!
-Dave


What happens to this data when the form is submitted? They are entered
into a database?

These look like prices. You don't really want the customer submitting
their own prices. I could make a form that submits any price I want
based on this type of setup. Hidden isn't really hidden. If you use
"View Source" in your browser you can see it. Unless you are doing some
server-side processing you may sell option 2 to me for $0.01. You
probably want to submit only the 1, 2, or 3 and then on the server-side
match the selection with the price.

Peter

Apr 25 '06 #2
The form submits to a database on an e-commerce host.

Thanks for the heads up on the possibility of someone posting
fraudulant prices... I was aware of that hole and will be addressing
that.

Any input on how to do what I'm trying to with javascript?

Thanks!

Apr 25 '06 #3

No... probably won't do it that way... but I'm interested in seeing the
working code now since I spent so much time on it...

Apr 26 '06 #4
dv****@ix.netcom.com said on 26/04/2006 1:42 PM AEST:
No... probably won't do it that way... but I'm interested in seeing the
working code now since I spent so much time on it...


Change the type of the input to hidden:

<script type="text/javascript">

function update(sel, tgt)
{
tgt.value = sel.options[sel.selectedIndex].value;
}

</script>

<form action=""><div>
<input type="text" name="t01">
<select name="s01" onchange="update(this, this.form.t01)">
<option value="">Select an option
<option value="9.99">1
<option value="12.99">2
<option value="15.99">3
</select>
</div></form>


--
Rob
Group FAQ: <URL:http://www.jibbering.com/FAQ>
Apr 27 '06 #5

Thanks so much for the response Rob!

That is almost what I'm going for... what if I wanted to populate "t01"
with values that are different from the values in "s01". For example,
when option 1 is selected with a value of 9.99, t01 gets a value of
3.50... when option 2 is selected with value of 12.99, t01 gets a value
of 4.00... and when option 3 is selected, t01 gets a value of 4.50.
Possible?

Thanks again for your help... if it takes too much effort don't worry
about it.

-Dave


RobG wrote:
dv****@ix.netcom.com said on 26/04/2006 1:42 PM AEST:
No... probably won't do it that way... but I'm interested in seeing the
working code now since I spent so much time on it...


Change the type of the input to hidden:

<script type="text/javascript">

function update(sel, tgt)
{
tgt.value = sel.options[sel.selectedIndex].value;
}

</script>

<form action=""><div>
<input type="text" name="t01">
<select name="s01" onchange="update(this, this.form.t01)">
<option value="">Select an option
<option value="9.99">1
<option value="12.99">2
<option value="15.99">3
</select>
</div></form>


--
Rob
Group FAQ: <URL:http://www.jibbering.com/FAQ>


Apr 27 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Andrea | last post by:
Hi, I'm trying to emulate part of our client-server application as a web site so customers can use it, and I'm stuck when it comes to re-ordering items in a list. Basically we have a list of...
12
by: Kevin Lyons | last post by:
Hello, I am trying to get my select options (courses) passed correctly from the following URL: http://www.dslextreme.com/users/kevinlyons/selectBoxes.html I am having difficulty getting the...
4
by: kaeli | last post by:
All, I have need of a readonly select element that looks and acts disabled to the user. The problem with the disabled attribute is that the value isn't passed to the handler, so I'm using...
2
by: Chris Plowman | last post by:
Hi all, I was wondering if anyone can help me with a really annoying problem I have been having. I made a derived datagrid class that will select the row when a user clicks anywhere on a cell...
11
by: pmarisole | last post by:
I am trying to use the vbscript "split" function on a multi-select field. I am trying to do a mass update of several records at a time. I am getting an error and I'm not sure what to do. Here is...
2
by: Rob Long | last post by:
Hi I have an HTML select element in my page and it's multiple property is disabled (one item at a time mode) but I still want to transfer all the items in the select to the server when the form...
1
by: nithingujjar | last post by:
Hi, I need to to hide a field"addr_state1" based on a value in the drop down list field called "addr_country".i.e.,if addr_country.value=="in" then hide addr_state1 else , and if the value in the...
5
by: laredotornado | last post by:
Hi, Is there a way to trigger an event when the value of a hidden field changes? At a certain point in time my hidden field is getting changed to a value that I don't want but I can't find a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.