SitePoint Sponsor |
|
User Tag List
Results 1 to 8 of 8
Thread: Get form value with javascript
-
Sep 25, 2001, 04:16 #1
- Join Date
- Mar 2001
- Posts
- 34
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Get form value with javascript
Hi,
I have a form with two fields, Item_Price and Item_Name
Item_Price looks like this:
<select name="Item_Price">
<option value="19.95">24" x 36" - Photo Glossy Paper</option>
<option value="24.95">24" x 36" - Satin Finish Paper</option>
</select>
Item_Name needs some javascript to do this:
<input type=hidden name="Item_Name" value="get the value of Item_Price option (not option value)">
Thanks in advanceLast edited by ee-o; Sep 25, 2001 at 04:19.
-
Sep 25, 2001, 14:56 #2
- Join Date
- Mar 2001
- Posts
- 34
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Does anyone know how to do this
-
Sep 26, 2001, 06:51 #3
-
Sep 26, 2001, 10:14 #4
- Join Date
- Mar 2001
- Posts
- 34
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Thanks Makeda,
Ill be waiting for you.
-
Sep 26, 2001, 10:47 #5
- Join Date
- Jun 2001
- Location
- rollin' on dubs
- Posts
- 492
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Here is something that will work..at least with IE. The function is attatched to the onChange event for the dropdown menu. I didn't write any onload events or anything so this thing will start working once you change the dropdown menu for the first time. You can easilly modify it to your liking:
<html>
<head>
<script language="javascript">
function writeHiddenValue(refDropDown) {
sOtherVal = frmElForm.Item_Price[refDropDown.selectedIndex].otherVal;
frmElForm.Item_Name.value = sOtherVal;
}
function testFunction() {
alert(frmElForm.Item_Name.value)
}
</script>
</head>
<body>
<form name="frmElForm" method="" action="">
<select name="Item_Price" onChange="writeHiddenValue(this);">
<option value="19.95" otherVal="24 x 36 - Photo Glossy Paper">24" x 36" - Photo Glossy Paper</option>
<option value="24.95" otherVal="24 x 36 - Satin Finish Paper">24" x 36" - Satin Finish Paper</option>
</select>
<input type=hidden name="Item_Name" value="">
<p />
<div align="center"><input type="button" value="Click Here To View Hidden Value" onClick="testFunction();"></div>
</form>
</body>
</html>
-
Sep 26, 2001, 10:52 #6
- Join Date
- Jun 2001
- Location
- rollin' on dubs
- Posts
- 492
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
one other thing, i noticed that you had some quotes in your values. I don't know what you're doing but one possible work around is using ". It works in the alert boxes or you could write a little regEx to put them in:
<option value="19.95" otherVal="24" x 36 - Photo Glossy Paper">24" x 36" - Photo Glossy Paper</option>
<option value="24.95" otherVal="24" x 36 - Satin Finish Paper">24" x 36" - Satin Finish Paper</option>
update: this bulletin board is rendering my HTML encoded quotation marks. my work around is to put the HTML encoded version of " next to your numbers. follow?
-
Sep 26, 2001, 22:36 #7
- Join Date
- Mar 2001
- Posts
- 34
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi Makeda,
I sent you a private message,
Thanks
-
Sep 27, 2001, 10:09 #8
Bookmarks