javascript-updating form with "onchange" on a sele
Posted: Mon Sep 30, 2002 1:24 pm
I thought this was simple enough that even I couldn't screw it up, but I guess i'm wrong. What I'm trying to do here is update a price(I use PHP and don't wanna do refreshes, so i'm using a seperate javascript function). I'm taking it one step at a time, and right now am just trying to change the text form with "onchange" on the select, but I get an error: window.document.formprice.currentprice is null or not an object. Can anyone tell me where I screwed it up? I'm sure it's something simple, but I just don't see it. Code's below. TIA
In <head>
<script language="JavaScript">
function updateprice()
{
window.document.formprice.currentprice.value = "value has changed"
}
</script>
.
.
.
.
later...
.
.
<form name="formprice">
<input type="text" name="currentprice"
value="Current Price">
</form>
.
.
.
little bit later....
.
.
.
//this is a mix of PHP and javascript-you can ignore the PHP, it just creates the selections......
//end of comment
echo '<tr><td class="main">' . $products_options_name_values['products_options_name'] . ': </td><td>' . "\n" . '<select name ="id[' . $products_options_name_values['products_options_id'] . ']"onchange="updateprice()">' . "\n";
In <head>
<script language="JavaScript">
function updateprice()
{
window.document.formprice.currentprice.value = "value has changed"
}
</script>
.
.
.
.
later...
.
.
<form name="formprice">
<input type="text" name="currentprice"
value="Current Price">
</form>
.
.
.
little bit later....
.
.
.
//this is a mix of PHP and javascript-you can ignore the PHP, it just creates the selections......
//end of comment
echo '<tr><td class="main">' . $products_options_name_values['products_options_name'] . ': </td><td>' . "\n" . '<select name ="id[' . $products_options_name_values['products_options_id'] . ']"onchange="updateprice()">' . "\n";