Hi all,
please, help me with jquery - I'm totally amateur in javascript.
I use script to assign the value to item selected from html select box.
The second script adds row into my form.
The first row works o.k. but if I´m adding another rows, only value from the first row is functional.
Thanks for any advice. Petr
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/jquery.table.addrow.js"></script>
<script type="text/javascript">
(function($){
$(document).ready(function(){
$(".addRow").btnAddRow();
$(".delRow").btnDelRow();
});
})(jQuery);
</script>
<script type="text/javascript">
var message = new Array()
message["Acoustic"]="3000";
message["Electric"]="500";
$(document).ready(
function (){
$(".item_select").change(function()
{
var message_index
message_index = $(".item_select").val();
$(".message_display").empty();
//if (message_index > 0)
$(".message_display").append(message[message_index]);
//$("input").val(message_index);
$(".price").val(message[message_index]);
});
});
</script>
</head>
<body>
<br />
<br />
<font color='#CC3300' size='5'>Catalogue</font><br />
<br />
<form method='POST' name='signupForm' class='cmxform' id='signupForm' action='#'>
<table cellspacing='0'>
<tr>
<th style='text-align: center;'></th>
<th>Model</th>
<th>Price</th>
</tr>
<tr>
<td><input type='button' class='delRow' style='height: 25px; margin: 0 0 10px 0;' value='X'/></td>
<div>
<td><select class='item_select' name='item_select' style='width:200px; margin: 0 0 10px 0;'>
<option value='Acoustic'>Acoustic</option>
<option value='Electric'>Electric</option>
</select>
</td>
<td><input type='text' name='price' class='price' style='margin: 0 0 10px 0;' size='2' value=''></td>
</div>
</tr>
<tr>
<td colspan='3' align='right'><input type='button' class='addRow' name='add' value='Add Row'/></td>
</tr>
<tr>
<td colspan='5' align='center'><input type='submit' name='send' value='Send'></td>
</tr>
</table>
</form>
</body>
</html>