I have a form using CI's form_dropdown that pulls an array from DB....
$osValue = 'id = "osValue"'; echo form_dropdown('os', $os, '', $osValue); which, when inspecting the element, is as follows in the user agent...
<select name="os" os> <option value="1">Windows XP 32-bit</option> <option value="2">Windows XP 64-bit</option> <option value="3">Windows Vista 32-bit</option> <option value="4">Windows Vista 64-bit</option> <option value="5">Windows 7 32-bit</option> <option value="6">Windows 7 64-bit</option> <option value="7">Server 2003 32-bit</option> <option value="8">Server 2003 64-bit</option> <option value="9">Server 2008 32-bit</option> <option value="10">Server 2008 64-bit</option> <option value="11">Linux</option> </select> What I'm having trouble with is being able to pass ONLY the SELECTED value into a variable.
I get ALL options returned, when using
var os = $('#osValue').html(); or
var os = $('#osValue').text(); And, only the value (a numerical string passed in by the DB) is returned when using
var os = $('#osValue').val(); There has to be a small piece or two that I'm missing in order to have only the selected value returned. Any/all advice or help would greatly appreciated. Thank you in advance!
<select name="os" os>seems defective, make sureform_dropdown()works properly. Second, what's wrong with.val()?