[thelist] Simple JavaScript question

john at johnallsopp.co.uk john at johnallsopp.co.uk
Sat Jul 8 10:35:38 CDT 2006

Hi ppl

I'm not very great on JavaScript, I spend most of my time in PHP, so
here's a really simple question for you.

I've a function that's intended to change the displayed price each
time someone chooses from various select options.

So I've got:
<script language='JavaScript'>
	function changePrice(pOption)
	 // get what user selected
	 ind = document.giftOpts.pOption.selectedIndex;
	 val = document.giftOpts.pOption.options[ind].text;
	 window.alert ('Debug: Inside javascript: changePrice');

I don't know how to make pOption, which is the name of the select tag
passed as a parameter into the function, be interpreted properly when
it's inside document.giftOptions.pOption.selectedIndex. I've tried
various combinations of getElementById and I've worked through all my
notes but it ain't happening.

Gimme a clue.

The select part goes like this:

<form method='post' action='index.php4' name='giftOpts'><select
name='abc' onChange='changePrice(abc)'>";


More information about the thelist mailing list