dlebowski Posted October 24, 2010 Share Posted October 24, 2010 I want to change the SELECT value based off of a javascript variable value. For example, I want var myvariable = NULL; If myvariable = ONLINE do this: <label class="solddropdown" style="display: none;"> <select id='onlineonsite' style="font-size: 10px;"> <option value="ONLINE" SELECTED >ONLINE</option> <option value="ONSITE" >ONSITE</option> </select> </label> else If myvariable = ONSITE do this: <label class="solddropdown" style="display: none;"> <select id='onlineonsite' style="font-size: 10px;"> <option value="ONLINE" >ONLINE</option> <option value="ONSITE" SELECTED >ONSITE</option> </select> </label> Any help on this would be greatly appreciated! Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/216735-change-the-select-value-in-drop-down-based-off-of-a-javascript-variable-value/ Share on other sites More sharing options...
mentalist Posted October 26, 2010 Share Posted October 26, 2010 You'll need to somehow identify each item in your list, probably by using id, then you'll need to (i'm assuming here) change the selected property from 'selected' to '' and vice versa, but that seems mad, so after a quick search... http://www.mredkj.com/tutorials/tutorial002.html Quote Link to comment https://forums.phpfreaks.com/topic/216735-change-the-select-value-in-drop-down-based-off-of-a-javascript-variable-value/#findComment-1126599 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.