wood burning stoves 2.0*
The moose likes HTML, CSS and JavaScript and the fly likes How to retreive value attribute of the html:option tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "How to retreive value attribute of the html:option tag" Watch "How to retreive value attribute of the html:option tag" New topic
Author

How to retreive value attribute of the html:option tag

Shyam kumar
Ranch Hand

Joined: May 21, 2006
Posts: 146
I have the following select tag:

<html:select property="college" onchange="populateCourse();" >
<html ption value="IPU" >IP University</html ption>
<html ption value="DU">Delhi University</html ption>
<html ption value="GJU">GJU</html ption>
</html:select>

I want to retreive the attribute value of <html ption> tag in populateCourse() javascript. The statement document.getElementById("college").selectedIndex is giving me integer index whereas document.getElementById("college").value is giving me the display value like IP University instead of attribute value IPU

How can i do this?
jeff rusty
Ranch Hand

Joined: Nov 07, 2006
Posts: 109
Naveen ,
can you post the code which you have written in the javascript function populateCourse()and "document.getElementById("college").value" will return only the attribute value and not the text in <html ption> or in normal <option> unless you have tried to retrieve the text like this
"document.getElementById("college").options[0].text".
[ December 03, 2006: Message edited by: prem kamal ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to retreive value attribute of the html:option tag