FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

Javascript: Drop Down Box Help

 


moejoe
Hey Guys.

Is there a Way to Call Out the Value in Between the <option> tag?

Eg:
<select name="D1">
<option value=Something>Something Else</option></select>
^
|| Can You Use JS to Call this Value rather then making the value="" equal too it??

Thanks in Advance.
smartbei
If you treat the option as a regular text container, then you can assign it an ID and use innerHTML:

Code:

<script>
function callOut() {
   alert(document.getElementById('option1').innerHTML);
}
</script>
<form>
<select>
<option id='option1' value="Something1">Something Else1</option>
</select>
<input type="button" onClick="callOut()" />
</form>
Reply to topic    Frihost Forum Index -> Scripting -> Html, CSS and Javascript

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.