RoninStretch Posted May 4, 2007 Share Posted May 4, 2007 I have a few listboxes that list the values 1-10. What i'm doing is checking the database and getting a 1-10 result in a variable. I can't seem to use that to set which value is selected on page load. <select name='editbox' value='$edit'> <option value='1'>1</option> <option value='2'>2</option> <option value='3'>3</option> <option value='4'>4</option> <option value='5'>5</option> <option value='6'>6</option> <option value='7'>7</option> <option value='8'>8</option> <option value='9'>9</option> <option value='10'>10</option> </select> Where $edit = 6 the listbox would load with 6 already selected.. Any ideas, i've been searching around for a while now but it's always to do with submitting the listbox data. Quote Link to comment Share on other sites More sharing options...
DaveEverFade Posted May 4, 2007 Share Posted May 4, 2007 echo " <select name='editbox' value='$edit'> <option ".($edit==1?"selected":"")." value='1'>1</option> <option ".($edit==2?"selected":"")." value='2'>2</option> <option ".($edit==3?"selected":"")." value='3'>3</option> etc.... </select> "; Quote Link to comment Share on other sites More sharing options...
RoninStretch Posted May 4, 2007 Author Share Posted May 4, 2007 Ah thank you very much Quote Link to comment Share on other sites More sharing options...
DaveEverFade Posted May 4, 2007 Share Posted May 4, 2007 No worries, just noticed tho, you don't need that value='$edit' in there... Quote Link to comment 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.