i used the same techniqu a while back when i worked with Fast Template. scenario: - present a user with a form to input - there are several text fields and several select options - if there is/are error(s) upon form submission, we will call the same template file and insert proper error messages at appropriate places, normally close to the input field. - we would also luv to make the select option field to DEFAULT to the PREVIOUS value that WAS selected.
with the technique that Nathan describe below, you can do just that. At present i have dropped this technique as I have switched to Smarty. Smarty can do all this with its {html_optios blah blah blah}. Recently I made frequent use of Webreference javascript to make select boxes that are related to each other. ie changing(selecting) a left select box would make a right select box change accordingly. I am trying to apply Smarty to this but my javascript knowledge is too shallow. after submitting a form with errors, the 2 select boxes will default back when the script starts. which is NOT what i want. if nebody have done this, appreciate your help. -- roger --- Nathan Cook <[EMAIL PROTECTED]> wrote: > You may already be doing it like this, but I think I found a new way to > make select boxes auto-select (what data they put in) a lot easier. All you > have to do is put a variable in each select tag that is equal to the value > of the select option i.e.: <option value=teacher $teacher> -- then all you > have to do is base the variable on that <select name=interest> $$interest = > "selected"; quick and easy with out having to loop through an if elseif > statement. Let me know if you like that method or have any objections. > > Full example below. > > print("<select name=interest>\n"); > // creates a variable with a name based on > // the value of interest with a value of "selected" > $$interest = "selected"; > print("<option value=>- Select One -</option>\n"); > print("<option value=teacher $teacher>Teacher</option>\n"); > print("<option value=lego $lego>Lego Enthusiast</option>\n"); > print("<option value=student $student>Student</option>\n"); > print("<option value=homeschool $homeschool>Homeschool Parent</option>\n"); > print("<option value=browsing $browsing>Browsing</option>\n"); > print("<option value=afterschool $afterschool>Afterschool</option>\n"); > print("<option value=bgca $bgca>Boys & Girls Club</option>\n"); > print("<option value=ymca $ymva>YMCA</option>\n"); > print("</select> \n"); > > [ Nathan Cook | [EMAIL PROTECTED] ] > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > __________________________________________________ Do You Yahoo!? Yahoo! Health - Feel better, live better http://health.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php