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 - 02:15 PM

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
  • 3,318 posts

Posted 31 December 2012 - 02:33 PM

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.

Please: "This doesn't work..." is not a question.  We're not the government: we don't have anything to view what your doing on your computer.  Help us help you by asking a good question.

 

"Things needed to ask a "good" question:

  • A description of the context of your issue (Optional but can be a huge help in certain circumstances)
  • What is the actual problem (Mandatory)
  • What does the code actually do (Mandatory)
  • What you think the code should do / What you want the code to do (Mandatory)
  • What things have you tried so far (Optional, but missing it out just wastes your time and ours)
  • The actual code as you are running it - minus any personal information like Database Login Credentials (Mandatory - don't just post pseudo, the vast majority of issues are syntax and not logic)
  • As much info about your development environment as you can give - even if it's just letting us know you are using a hosting provider instead of a local install (Optional, but some questions can not be answered without it.)

 

 

My SQL/PHP Blog


#3 mds1256

mds1256

    Advanced Member

  • Members
  • PipPipPip
  • 199 posts

Posted 31 December 2012 - 02:37 PM

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
  • 3,318 posts

Posted 31 December 2012 - 02:49 PM

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

Please: "This doesn't work..." is not a question.  We're not the government: we don't have anything to view what your doing on your computer.  Help us help you by asking a good question.

 

"Things needed to ask a "good" question:

  • A description of the context of your issue (Optional but can be a huge help in certain circumstances)
  • What is the actual problem (Mandatory)
  • What does the code actually do (Mandatory)
  • What you think the code should do / What you want the code to do (Mandatory)
  • What things have you tried so far (Optional, but missing it out just wastes your time and ours)
  • The actual code as you are running it - minus any personal information like Database Login Credentials (Mandatory - don't just post pseudo, the vast majority of issues are syntax and not logic)
  • As much info about your development environment as you can give - even if it's just letting us know you are using a hosting provider instead of a local install (Optional, but some questions can not be answered without it.)

 

 

My SQL/PHP Blog





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users