Posted By

jakepaint on 07/24/07


Tagged

form php fields sticky stickies


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

depmed
kwiveo


Sticky Form Fields


 / Published in: PHP
 

Consise code for sticky forms

  1. $name = $_POST['name'];
  2. $gender = $_POST['gender'];
  3. $howlong = $_POST['howlong'];
  4.  
  5. ****************
  6.  
  7. function sticky($field) {
  8. if(isset($field))
  9. return $field;
  10. }
  11. function stickyradio($name,$value) {
  12. if ($name == $value) {
  13. return ' checked="checked" ';
  14. }
  15. }
  16.  
  17. function stickymenu($name,$value) {
  18. if ($name == $value) {
  19. return ' selected="selected" ';
  20. }
  21. }
  22.  
  23. ***************
  24.  
  25. <input type="text" name="name" value="'.sticky($name).'" />
  26. <input type="radio" name="gender"'.stickyradio($gender,'male').'value="male" />
  27. <option value="1y"'.stickymenu($howlong,'1y').'>1 year</option>

Report this snippet  

You need to login to post a comment.