...

View Full Version : Usins SELECT tag with javascript



anandc
08-26-2002, 01:30 PM
Hi

I m new to HTML and Javascript.
What I want to do is when the user select some text
from the Drop Down List, it should get displayed in
the web Page.

suppose the SELECT tag contains:-
India
USA
UK

and if the user selects USA. then it should get
displayed in the Webpage in Bold with font color as
Red

Please tell me how to do this

premshree
08-26-2002, 02:45 PM
Here's the code :
(Wont work with NS 4.X)



<html>
<head>
<title>Select</title>
<script language="JavaScript">
function displayOption(divName)
{
document.getElementById(divName).innerText=document.form1.select1.options[document.form1.select1.selectedIndex].value;
}
</script>
</head>
<body bgcolor="#FFFFFF">

<!--BEGIN FORM-->
<form name="form1">
<select name="select1" onChange="displayOption('div1');">
<option value="India">India</option>
<option value="USA">USA</option>
<option value="UK">UK</option>
</select>
</form>
<!--END FORM-->

<div id="div1" style="font-family:verdana,arial,helvetica; font-weight:bold; color:#FF0000"></div>

</body>
</html>


:thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum