Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript_howto thread: Opening a textbox on a form dependent on the select box's value


Message #1 by "Michaela" <lanmbran@h...> on Fri, 28 Sep 2001 17:26:39
you should research the built-in events for the form controls, onClick,
onChange, etc...

I'm assuming what you want is the onChange() event for the <Select> tag

something like this:
<Select onChange="CheckSelection(this)">
	<option value="some value">Some Value</option>
	<option value="some value">Some Value</option>
	<option value="some value">Some Value</option>
	<option value="other">Other</option>	
</Select>
<script language="Javascript">
	function CheckSelection(oObject)
	{
		var lIndex = oObject.options.selectedIndex
		var sText = oObject.options[lIndex].value
		if (sText == 'other')
		{
			alert("Do you other function here")
		}
	}
</script>

-----Original Message-----
From: Michaela [mailto:lanmbran@h...]
Sent: Friday, September 28, 2001 1:27 PM
To: JavaScript HowTo
Subject: [javascript_howto] Opening a textbox on a form dependent on the
select box's value


Hi,

Bizarre title! I basically want to know where I can find code which will 
open a textbox so that someone can specify information if they 
select "Other" froma drop down list on my form. Does this make sense? 

I realise it's to do with if value=="Other" then 
                             do this
                          else
                             do the other

The thing is, I don't know what to use as a trigger? Does all this make 
sense? Hope so,

Any suggestions would be gratefully received!
Cheers,
Michaela

  Return to Index