473,468 Members | 1,358 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

automatic form element tab

Hello
Need help setting this up so that the value selected in the "Ship"-select
box, will appear in the "Price"-text box automatically. (before submitting
the form or clicking on the price box).
<td><select name="Ship">
<option value="" >Select</option>
<option value="500">A</option>
<option value="400">B</option>
<option value="300">C</option>
<option value="200">E</option>
<option value="600">D</option>
</select>
</td>
<td>$&nbsp;<input type="text" name="Price" value="" size="4"></td>
Thanks
SY
Jul 23 '05 #1
3 1348
"yacobson" <ya******@earthlink.net> wrote in message
news:s3*****************@newsread2.news.atl.earthl ink.net...
Hello
Need help setting this up so that the value selected in the "Ship"-select
box, will appear in the "Price"-text box automatically. (before submitting
the form or clicking on the price box).
<td><select name="Ship">
<option value="" >Select</option>
<option value="500">A</option>
<option value="400">B</option>
<option value="300">C</option>
<option value="200">E</option>
<option value="600">D</option>
</select>
</td>
<td>$&nbsp;<input type="text" name="Price" value="" size="4"></td>
Thanks
SY


Will this help? Watch for word-wrap.

<html>
<head>
<title>shiprice.htm</title>
<script type="text/javascript">
function ship(that) {
var form = document.forms[0];
var valu = form.Ship.options[form.Ship.selectedIndex].value;
form.Price.value = valu;
}
</script>
</head>
<body>
<form>
<table border="0">
<tr>
<td>
<select name="Ship" onchange="ship()">
<option value="">Select</option>
<option value="500">A</option>
<option value="400">B</option>
<option value="300">C</option>
<option value="200">E</option>
<option value="600">D</option>
</select>
</td>
<td>
$&nbsp;<input type="text" name="Price" value="" size="4">
</td>
</tr>
</table>
</form>
</body>
</html>
Jul 23 '05 #2
On Sun, 17 Oct 2004 14:10:32 GMT, yacobson <ya******@earthlink.net> wrote:
Need help setting this up so that the value selected in the
"Ship"-select box, will appear in the "Price"-text box automatically.
(before submitting the form or clicking on the price box).


The, "before submitting the form", part worries me a little. Make sure you
don't depend on this action happening. It might not.

[snip]

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #3
On Sun, 17 Oct 2004 16:03:54 GMT, McKirahan <Ne**@McKirahan.com> wrote:

[snip]
function ship(that) {
You add an argument, but you don't pass anything, nor do you use that
argument. That strikes me as a little odd. Did you forget about it?
var form = document.forms[0];
var valu = form.Ship.options[form.Ship.selectedIndex].value;
form.Price.value = valu;
Assuming you passed the argument, you could use:

var elem = that.form.elements;
elem['Price'].value = that.value;

If you want to use the options collection (though there shouldn't be any
need), change the last line to:

elem['Price'].value = that.options[that.selectedIndex].value;
}
[snip]
<select name="Ship" onchange="ship()">


The script changes above obviously require a change here:

<script name="Ship" onchange="ship(this);">

[snip]

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #4

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

Similar topics

6
by: Weng kin | last post by:
Hi everyone, I have a problem trying to load an image without the image resizing itself to fit into the window. My simple javascript is as follows: function viewImage(filename) { features =...
12
by: CJ | last post by:
Why won't this work? I am passing the name of the form (I have two that use this validation script) but I keep getting an error. Error reads: "document.which_form.name is null or not an object" ...
4
by: aure_bobo | last post by:
Hi all, I'm currently developping a web app, and this one must be compatible with IE and Mozilla Firefox. In this webapp, I would like to launch automatically a anchor link (href) with a...
4
by: Hman | last post by:
Hi, This is a two part question: 1)trying to serialize a read only class member. I have a public property with a get statement, but not set, hence read only. When I serialize the class,...
6
by: Gert van der Kooij | last post by:
Hi, It's no problem to define the automatic maintenance using the wizard but I want to use commands to automate automation. I captured the SQL statements when activating the maintenance but that...
2
by: sivad1178 | last post by:
Hello, I am creating a Javascript tool which will automatically and randomly fill in a multi-page form. It pops a new window, containing the multi-page form (both pages are on the same server...
3
by: mac | last post by:
I have a datagridview that I populate with the result of a web service. The webservice sends multiple rows back with each row as one element of an array. I use a for loop and the...
1
by: Michael Doubez | last post by:
Hello, I want to mix in the same document Parts that have automatically numbered sections and parts which section are not numbered. Is there any out of the box way to locally suppress the...
4
by: acw | last post by:
I am trying to understand how IE handles automatic tag variables. I know that IE will create a global variable each time it finds a tag with its name or id attribute set. If you have more than...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.