aspose file tools
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
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply 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://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: How to retreive value attribute of the html:option tag
 
Similar Threads
HTML:SELECT
how to fill a combobox with values from objects in an ArrayList...
for loop in select struts tag
update html:options
Help me regarding select value in html:select...