Jump to content
Larry Ullman's Book Forums

Recommended Posts

I came up with this for a sticky select (seems to work okay) but am curious if there is a simpler way. There will never be any more than 3 date options

      <select name="date_cats" style="font-size:smaller">
      <option value="Select Date Type" >Select Date Type</option>
        <option value="Date Sold" <?php if(isset($_POST['date_cats'])&& $_POST['date_cats']=="Date Sold") echo 'selected="selected"'; ?> >Date Sold</option>
        <option value="Date Added" <?php if(isset($_POST['date_cats'])&& $_POST['date_cats']=="Date Added") echo 'selected="selected"'; ?> >Date Added</option>
        <option value="Date Created"<?php if(isset($_POST['date_cats'])&& $_POST['date_cats']=="Date Created") echo 'selected="selected"'; ?> >Date Created</option>
      </select>
Link to comment
Share on other sites

If there are never going to be more than three possible values and this works, you're fine. The only way to simplify it would be to store the possible values in an array and use a loop to output the options. Within the loop you'd check for stickiness. But I don't know I'd make that change in this case. 

Link to comment
Share on other sites

Great. And, yes, I will never have to add <optiion> values to this.

 

Aside from this... I wish you could see the condition of my copy of PHP6 and MySQL 5. I have used it so much over the years it is disintegrating in my hands despite two applications of rubber cement and duct tape to the binding. I have gotten so much out of it. It sits on my desk, a programming bible , with thickening dog ears and dozens of multi-colored plastic tabs sticking out its fore edge shouting exclamations like "retrieving query results" ,"stick forms", "send values to a script" ... It has even survived exposure to a violent thunderstorm and 3 days under the July sun drying.

 

A great value in my programming arsenal which, when it finally slips through my fingers as pulp dust, I will not hesitate to purchase once again.

thanks for all that,

chop

Link to comment
Share on other sites

 Share

×
×
  • Create New...