Jump to content


Photo

Html Select - Add Selected


  • Please log in to reply
3 replies to this topic

#1 mds1256

mds1256

    Advanced Member

  • Members
  • PipPipPip
  • 199 posts

Posted 31 December 2012 - 09:15 AM

Hi

I have a Title select box on my website (Mr, Mrs, Miss, etc).

Now, if they enter something that does not meet the form validation, it reloads the page and populates the fields that has already been filled out along with the appropriate error message.

Now my question is what is the best way to add the selected value that was chosen on the initial filled out form so they dont have to re-select.

#2 Muddy_Funster

Muddy_Funster

    Advanced Member

  • Members
  • PipPipPip
  • 2,993 posts

Posted 31 December 2012 - 09:33 AM

check the value as it's being rendered and if it's the matching one from the previous submition add the selected="selected" to the option.
A simple password hash :

function makePass($word=''){
  $dbSalt = '$2a$07$'.substr(hash('whirlpool',$word),0,22);
  $dbPass = crypt($word, $dbSalt);
 return substr($dbPass,12);
}



My SQL/PHP Blog

#3 mds1256

mds1256

    Advanced Member

  • Members
  • PipPipPip
  • 199 posts

Posted 31 December 2012 - 09:37 AM

check the value as it's being rendered and if it's the matching one from the previous submition add the selected="selected" to the option.


Will that not mean there will be lots of if statements?

#4 Muddy_Funster

Muddy_Funster

    Advanced Member

  • Members
  • PipPipPip
  • 2,993 posts

Posted 31 December 2012 - 09:49 AM

depends on how you are populating your select element, which without code I can't see :P
A simple password hash :

function makePass($word=''){
  $dbSalt = '$2a$07$'.substr(hash('whirlpool',$word),0,22);
  $dbPass = crypt($word, $dbSalt);
 return substr($dbPass,12);
}



My SQL/PHP Blog




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com