westman Posted February 3, 2013 Share Posted February 3, 2013 hi there am working with <option> in php this is my code HTML <div align="left"> <select name="selected_itme" id="selected_item"> <option value="">Select your item</option> <?php echo $select_body ?> <?php echo $select2_body ?> </select> </div> PHP $select_body .= '<option value="' . $select_id . '">' . $select_name . '</option>'; $select2_body .= '<option value="' . $select2_id . '">' . $select2_name . '</option>'; $select_body and $select2_body are in different while loops from different DB's and working well.however how do i find out witch $select_body was selected?i tried using... $select2_body .= '<option onchange="javascript:itemtype(\'123\');" value="' . $select2_id . '">' . $select2_name . '</option>'; and $select2_body .= '<option onclick="javascript:itemtype(\'123\');" value="' . $select2_id . '">' . $select2_name . '</option>'; but it did not work.any help? Link to comment Share on other sites More sharing options...
jeffman Posted February 3, 2013 Share Posted February 3, 2013 A option element does not support the change event. The select element does. The select element also has a .value property that you can test in javascript. It returns the value property of the currently selected option. FWIW, you're using a really old way of responding to events. Here's an explanation of better options. Read the whole document. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now