[Javascript] form array2 values
Flavio Gomes
flavio at economisa.com.br
Wed May 4 09:04:31 CDT 2005
Michael, let me see if I got you correctly:
=======================
<form name=myForm>
<select name=myProducts onchange="updPrice(this)">
<option value=0> My 1 € product </option>
<option value=1> It's worthy 5 €! </option>
<option value=2> This one is 20 € only </option>
</select>
<input name=myPrice type=text READONLY value =" 0.00 €">
<script>
var myProductsPrices = new Array(1,5,20);
// Array with prices
function updPrice(mySelect)
{
var myOption = mySelect.options[mySelect.selectedIndex];
var myForm = mySelect.form;
myForm.myPrice.value = myProductsPrices[myOption.value] + ".00 \€";
// PS.: Couldn't make the € stuff works on this line
}
</script>
=======================
Michael Borchers wrote:
>I have an array starting with 0 and ending with 5.
>I need my function to change the products_id[0][products_price] field with the desired price
>regarding the products_id[0][products_id] field. how can i realize this?
>
>
><form action="..." method="post" name="orders">
><select name="products_id[0][products_id]">
>...
></select>
><input type="text" name="products_id[0][products_price]" id="0" value="0,00 €" size="10" onFocus="products_id2products_price(0)">
>...
></form>
>
><script language="JavaScript" type="text/javascript">
>function products_id2products_price(NUM_ROWS)
>{
> var products_id = document.orders.products_id[NUM_ROWS][products_id];
>
> if(products_id == '1') { var products_price = '229.0000'; }
> if(products_id == '3') { var products_price = '149.0000'; }
>
> document.orders.products_id[NUM_ROWS][products_price].value = products_price;
>}
>_______________________________________________
>Javascript mailing list
>Javascript at LaTech.edu
>https://lists.LaTech.edu/mailman/listinfo/javascript
>
>
--
Flavio Gomes
flavio at economisa.com.br
More information about the Javascript
mailing list