Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to retreive value attribute of the html:option tag

 
Shyam kumar
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic