how to copy an option value in form list to an input field with javascript -
i'm new javascript , need in matter:
i've created select field on form has options have numeric value. need copy value field in order add several options. i've found code copy text input field , and selection input field not option value.
this code i've written far:
<html> <head> <script type="text/javascript"> function id( el ){ return document.getelementbyid( el ); } function getmoney( el ){ var money = id( el ).value.replace( ',', '.' ); return parsefloat( money )*100; } function soma_oferta() { var total = getmoney('campo16')+getmoney('campo17')+getmoney('campo18')+getmoney('campo19')+getmoney('campo20')+getmoney('campo21'); id('campo22').value = total/100; } </script> </head> <body> <form action="" method=""> <table width="304" border="0" cellspacing="0" cellpadding="0"> <tr> <th colspan="2" align="center" bgcolor="#999999" scope="col"><h3>box</h3></th> </tr> <tr> <td width="145" bgcolor="#999999" scope="col"><label for="textfield8"></label> box 1: <label for="select9"></label></td> <td width="159" bgcolor="#999999" scope="col"><select name="select9" id="select9"> <option value="5">option 1</option> <option value="10">option 2</option> <option value="15">option 3</option> </select></td> </tr> </table> <p> </p> <table width="520" border="0" cellpadding="0" cellspacing="0"> <tr> <th colspan="2" align="center" bgcolor="#999999" scope="col"><h3> </h3></th> </tr> <tr> <td width="98" align="center" bgcolor="#999999" scope="col">base:</td> <td width="165" bgcolor="#999999" scope="col"><input name="campo16" id="campo16" value="0,00" /></td> </tr> <tr> <td align="center" bgcolor="#999999" scope="col">box 1:</td> <td bgcolor="#999999" scope="col"><input name="campo16" id="campo17" value="0,00" /></td> </tr> <tr> <td align="center" bgcolor="#999999" scope="col">box 2:</td> <td bgcolor="#999999" scope="col"><input name="campo16" id="campo18" value="0,00" /></td> </tr> <tr> <td align="center" bgcolor="#999999" scope="col">box 3:</td> <td bgcolor="#999999" scope="col"><input name="campo16" id="campo19" value="0,00" /></td> </tr> <tr> <td align="center" bgcolor="#999999" scope="col">extra 1</td> <td bgcolor="#999999" scope="col"><input name="campo16" id="campo20" value="0,00" /></td> </tr> <tr> <td align="center" bgcolor="#999999" scope="col">extra2:</td> <td bgcolor="#999999" scope="col"><input name="campo16" id="campo21" value="0,00" /></td> </tr> <tr> <td colspan="2" bgcolor="#999999" scope="col"> </td> </tr> <tr> <td bgcolor="#999999"> </td> <td bgcolor="#999999"> </td> </tr> <tr> <td align="center" bgcolor="#999999">total:</td> <td bgcolor="#999999"><input name="campo16" readonly id="campo22" /></td> </tr> <tr> <td colspan="2" align="center" bgcolor="#999999"><input type="button" onclick="soma_oferta()" value="calculate" /></td> </tr> </table> <p><br /> <br /><br /><br /> <br /><br /> </p> </form> </body> </html>
you can selected value of <select>
with:
id('select9').value
Comments
Post a Comment