Michael Winter wrote:[color=blue]
> *On Tue, 17 Feb 2004 00:38:15 -0600, John C
> <John.C.11rf4p@mail.forum4designers.com> wrote:
>[color=green]
> > I know absolutely nothing about JavaScript but I am told tha[/color]
> JavaScript[color=green]
> > is needed to solve my Form problem. I�m trying to figure out ho[/color]
> to[color=green]
> > take 2 List fields that would have text names but would represent
> > numeric values and calculate them..[/color]
>
> [snip]
>[color=green]
> > Then I would like to multiply the numeric value of the selecte[/color]
> item in[color=green]
> > the first List field by the numeric value of the selected item i[/color]
> the[color=green]
> > second List field and put the result into a text field calle[/color]
> �Price�.[color=green]
> >
> > I would like to have the result appear in the Price field
> > automatically, as soon as the two items have been selected[/color]
> without[color=green]
> > having to click on a button.[/color]
>
> Though KC Wong gave you a good start, you said you know nothin
> about
> JavaScript, so I think a full solution would be more appropriate
> Below is
> a sample that should set you on your way.
>
> <script type="text/javascript">
> function updatePrice( formRef ) {
> var rate = parseFloat( formRef.rate.value );
> var time = parseInt( formRef.time.value, 10 );
>
> if( isNaN( rate ) || isNaN( time )) {
> formRef.price.value = formRef.price.defaultValue;
> } else {
> formRef.price.value = '$' + ( rate * time );
> }
> }
> </script>
> ...
> <form ... name="sponsor">
> <select name="rate" onchange="updatePrice(this.form)">
> <option value="n/a">Choose sponsorship option</option>
> <option value="40.0">Sponsor One</option>
> <option value="25.0">Sponsor Two</option>
> <option value="10.0">Sponsor Three</option>
> </select>
> <select name="time" onchange="updatePrice(this.form)">
> <option value="n/a">Choose sponsorship period</option>
> <option value="1">1 Month</option>
> <option value="2">2 Months</option>
> <option value="3">3 Months</option>
> </select>
> <input name="price" type="text" value="Please choose values">
> </form>
>
> Hope that helps,
> Mike
>
> --
> Michael Winter
>
M.Winter@blueyonder.co.invalid (replace ".invalid" with ".uk" t
> reply)[/color]
John