KevMull Posted July 9, 2008 Share Posted July 9, 2008 How do I get a LABEL value (rather than the actual value) from a selected item in a dropdown (select list) when processing a form's POST details? Link to comment https://forums.phpfreaks.com/topic/113914-accessing-dropdown-label-value/ Share on other sites More sharing options...
rajivgonsalves Posted July 9, 2008 Share Posted July 9, 2008 You can access a dropdown label value in javascript but not in the php POST you'll have to work on a workaround like put the value and the label in the value attribute <option value="1|Rajiv">Rajiv</option> and later process it in PHP, Hope its helpful Link to comment https://forums.phpfreaks.com/topic/113914-accessing-dropdown-label-value/#findComment-585347 Share on other sites More sharing options...
KevMull Posted July 9, 2008 Author Share Posted July 9, 2008 Many Thanks You know what i'm going to ask next? How do I pass it to javascript? Link to comment https://forums.phpfreaks.com/topic/113914-accessing-dropdown-label-value/#findComment-585510 Share on other sites More sharing options...
rajivgonsalves Posted July 10, 2008 Share Posted July 10, 2008 you can use if objSelect is the reference to the object alert(objSelect[objSelect.selectedIndex].value); // for the value alert(objSelect[objSelect.selectedIndex].text); // for the text(label) Link to comment https://forums.phpfreaks.com/topic/113914-accessing-dropdown-label-value/#findComment-586202 Share on other sites More sharing options...
KevMull Posted July 10, 2008 Author Share Posted July 10, 2008 Thanks, that works a treat. My js is a bit rusty after being using .net for a few years and now having to chenge to php, which I have never used before! Link to comment https://forums.phpfreaks.com/topic/113914-accessing-dropdown-label-value/#findComment-586242 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.