Jump to content

Drop down Menu Select?


ghi572000

Recommended Posts

Hi, I'm no pro at PHP but I am trying to get a drop down menu to a authenticate before moving to the next part of the form.

 

What I want is once a selection has been made, ONLY THEN can the user move on, OTHERWISE a message echo appears.

 

This is the html menu box

 

<select size="1" name="title">

                    <option>Please Select</option>

                    <option value="Mr">Mr</option>

                    <option value="Mrs">Mrs</option>

                    <option value="Miss">Miss</option>

                    <option value="Ms">Ms</option>

                    <option value="Dr">Dr</option>

                  </select>

 

Then this is what I have in the form PHP:

 

$visitortitle = $_POST['visitortitle'];

 

if ( HOW DO I GET THIS PART TO AUTHENTICATE AN OPTION HAS BEEN SELECTED? ) {

echo "<p>Please enter a title correctly<br />before you try submitting the form again.</p>\n";

die ( '<a href="pef.html">click here go back and try again</a>' );

echo $id;}

 

If anyone can help me sort out this part of the form I can move on as the rest is working fine?

 

Thanks

Gary

 

Link to comment
Share on other sites

To validate form data without it getting submitted you have to use JavaScript.

This is because PHP is interpreted on the server, so you have to make a request to the server for it to work(unless you use AJAX but that is a different story). Try looking into JavaScript form validation.

Link to comment
Share on other sites

is it not something like:

 

if (empty($_POST['title'])) {
echo "<p>Please enter a title correctly<br />before you try submitting the form again.</p>\n";
die ( '<a href="pef.html">click here go back and try again</a>' );
echo $id;}

 

i could be wrong.

 

 

Edit: Right, didn't read the question properly.

Link to comment
Share on other sites

Okay, thanks it sounds like this is going to be a bit difficult and a bit over my head, however is there a easier way just for a selection to be made and then the user is able to move on to the next part of the form?

 

Unless anyone can show me an example of how I could use the AJAX option detailed?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.