Click to See Complete Forum and Search --> : [RESOLVED] Quick question about jump menus


andidas311
07-24-2009, 09:32 AM
Hi there, please take a look at this page of my website:

http://www.banded.co.uk/signup.html

The first field of the form at the bottom has around 14 options from a drop down selection. The first 7 do nothing special at this stage however the following 7 redirect to this url...

http://www.banded.co.uk/signup_v.html (http://www.banded.co.uk/signup.html)

...which is a variant of the same form (note that now the first and second groups of 7 options have reversed roles).

If a user choses an option that redirects to the alternate form version, how can I make it so that the new form loads with the option chosen already in the field, rather than returning to "please select".

Thanks in advance

peachskittle
07-24-2009, 03:12 PM
Hiya. There's a couple of ways you can do this... But here's what I would start with by saying...

It looks like you are giving different form options depending on their first field selection. I might recommend, under that Entry Form section, to just have that one field there. Then, once they make their selection, you can have that onchange load up whatever from they need. This way, they can't potentially swap back and fourth between the froms, whether intentionally or not.

This also means you won't have to worry about passing values from one page to another (I only sort of know the PHP solution to this, but if you insist on doing it the way you have now, we can try that.)

EDIT: You will probably still need that value that you get from that first select, so I might be wrong and you will still need to pass that to the next page, but then you can put it inside a hidden field or something...

andidas311
07-27-2009, 05:39 AM
Yeah I'm not too happy with the method I have in place at the moment.

In IE - everything works fine, the form redirects as necessary and the correct info is submitted.

In FireFox, the onChange command is making the browser look for pages that don't exist, as it's interpretting the first 7 options as redirection to other pages. Is there away to assign the "redirect" to field options, rather than the whole field?

EDIT: Also, is there a way to make "please submit" not a submittable option?

andidas311
08-09-2009, 08:53 AM
I've been toying around with this for a few weeks now and still don't have a solution.

peachskittle - you mentioned you might know of a php method to achieve this - what can you tell me?

peachskittle
08-10-2009, 09:27 AM
Hiya...

sorry took me while to get to this, have been feeling not too great and this heatwave sure isn't helping!

I did something like this a loooong while ago, and I'm trying really hard to remember.... it will be something like so:

http://bytes.com/topic/php/answers/3546-how-use-html-parameters-php

Where in the links you have in your drop down you will be adding a parameter

something.com?varname=value

Then, on the page that you are hitting with this drop down you tell it to get that variable and the value you have provided


<?php
if ($_GET['varname']=="value"){
echo "something";
} else {
echo "something else";
}'?>


In your case you may be wanting to display a block of HTML code depending on that if else. It may be easier to escape blocks of html than to try and squeeze it into an echo. This:

http://us2.php.net/manual/en/language.basic-syntax.phpmode.php

...allows you to place normal html after you close the php, but the if statement will still be in place and you can open it right back up to where you left off afterward.

andidas311
08-12-2009, 07:12 AM
Thanks for the reply peachskittle but I'm having some difficulty. I'd like to run by you what I'm aiming at and see if i'm on the right lines.

I've created a dummy page of my form here:http://www.banded.co.uk/signupnew.html

Now all of the drop-down options redirect to a page called action.php, and they each have their own variable and i.d.
action.php is supposed to detect which variable was clicked by the user and echo the relevant version of the form in place at the bottom.

So far I'm running into syntax errors so I've not had a successful trial of this.

Also, in the line:

if ($_GET['client']=="band"){

... how do I add other variables from the drop down menus so that the if statement can apply to a number of them, rather than just 1 at a time, is it literally "option1" , "option2" ,

peachskittle
08-12-2009, 10:01 AM
Hi

I need to see what's going on in your action.php, or you need to post the php for it completely here so I can help you.

To add conditions to the if, you can use and/or

and is "&&"

or is "||"

Ands and ors trip me up quite often. If you want to list several conditionals but have the if be true if one(or more) applies, use or.

andidas311
08-12-2009, 11:10 AM
Ok, here is a section of the code for page action.php
Thanks for your help on this!


<body>
<h1>Entry Form</h1>

<a name="join" id="join"></a>

<?php
if ($_GET['client']=="band"){
echo "<form method="post" action="sendmail.php">
<div id="entry1">
<p class="featured_text">
<span class="response2">*</span>You are a:<br />
<select name="client" id="client">
<option>Please Select</option>
<option>Band</option>
<option>Musician</option>
<option>Singer/Songwriter</option>
<option>Solo Artist</option>
<option>Audio Artist</option>
<option>MC</option>
<option>DJ</option>


</select>
<br />
If you selected &quot;Other&quot; please specify:<br />
<textarea name="otherspecify"onkeydown="limitText(this.form.otherspecify,this.form.countdown,25);"
onkeyup="limitText(this.form.otherspecify,this.form.countdown,25);" cols="2" rows="2"></textarea>
<br />
<span class="response2">*</span>Your Performing title:<br />
<input name="title" type="text" id="title"/>
<br /><span class="response2">*</span>You make this sound:<br />
<input name="sound" type="text" id="sound" size="50"/>
<br /><br /><br /><span class="response2">*</span>Your first name is:<br />
<input name="name" type="text" id="name" size="50"/>
<br /><span class="response2">*</span>Your contact number is:<br />
<input name="telnum" type="text" id="telnum" size="20" onkeypress="return numbersonly(this, event)"/>
<br /><span class="response2">*</span>Your contact email is:<br />
<input name="email" type="text" id="email" size="50"/>
<br />
</p>
</div>
<div id="entry">
<p class="featured_text"><span class="response2">*</span>Which Banded service interests you:<br />
<select name="service">
<option>Website</option>
<option>Logo</option>
<option>T-Shirt</option>
<option>Web Graphic</option>
<option>Posters/Flyers/Leaflets</option>
<option>Banner</option>
<option>Cover Art</option>
<option>Music Video</option>
<option>Stickers</option>
<option>Speciality (other)</option>

</select>
<input name="service_option_1" type="hidden" id="service" value="Website"/>
<input name="service_option_2" type="hidden" id="service" value="Logo"/>
<input name="service_option_3" type="hidden" id="service" value="T-Shirt"/>
<input name="service_option_4" type="hidden" id="service" value="Web Graphic"/>
<input name="service_option_5" type="hidden" id="service" value="Leaf"/>
<input name="service_option_6" type="hidden" id="service" value="Banner"/>
<input name="service_option_7" type="hidden" id="service" value="Cover Art"/>
<input name="service_option_8" type="hidden" id="service" value="Music Video"/>
<input name="service_option_9" type="hidden" id="service" value="Stickers"/>
<input name="service_option_10" type="hidden" id="service" value="Speciality"/>

<br />
If you selected &quot;Speciality&quot; please specify:<br />
<textarea name="specialityspecify"onkeydown="limitText(this.form.specialityspecify,this.form.countdown,25);"
onkeyup="limitText(this.form.specialityspecify,this.form.countdown,25);" cols="2" rows="2"></textarea><br /><br />

</p>
<p class="featured_text"> Please read the <a href="tnc.html">Terms and Conditions</a> before submitting your project.<br />
<br />
<input type="checkbox" name="accept" id="accept_0" class="radio"/><span class="response2">*</span>I accept the terms and conditions

<br /><br />
Please ensure you have completed all fields marked with <span class="response2">*</span> </p>
<input type="submit" name="submit" id="submit" class="button" value="Submit your project"/>



</div>
</form>";
} else {
echo "something else";
}'?>










</div>
</div>




<div id="footer"><p class="footer_text"><span class="highlight">Graphical promotion for your music and venue.</span><br />
2009 © Andi Best Illustration and Design.
All rights reserved. All content of this website is subject to copyright.<br />
<a href="index.html">Home</a> | <a href="music.html">Music</a> | <a href="venue.html">Venue</a> | <a href="signup.html">Sign Up</a> | <a href="tnc.html">Privacy Policy</a> | <a href="tnc.html">Terms and Conditions</a></p>
</div>




</body>

peachskittle
08-12-2009, 12:08 PM
Okay, I mentioned earlier something about escaping blocks of HTML code. The problem is right now, your echo is ending at the double-quote of method="post."

Either you have to backslash all of your double quotes between the echo double quotes (which I don't recommend ), or you should escape that ENTIRE block of HTML.


<?php
if ($_GET['client']=="band"){ ?>
<form method="post" action="sendmail.php">
<div id="entry1">
<p class="featured_text"> <span class="response2">*</span>You are a:<br />
<select name="client" id="client">
<option>Please Select</option>
<option>Band</option>
<option>Musician</option>
<option>Singer/Songwriter</option>
<option>Solo Artist</option>
<option>Audio Artist</option>
<option>MC</option>
<option>DJ</option>
</select>
<br />
If you selected &quot;Other&quot; please specify:<br />
<textarea name="otherspecify"onkeydown="limitText(this.form.otherspecify,this.form.countdown,25);"
onkeyup="limitText(this.form.otherspecify,this.form.countdown,25);" cols="2" rows="2"></textarea>
<br />
<span class="response2">*</span>Your Performing title:<br />
<input name="title" type="text" id="title"/>
<br />
<span class="response2">*</span>You make this sound:<br />
<input name="sound" type="text" id="sound" size="50"/>
<br />
<br />
<br />
<span class="response2">*</span>Your first name is:<br />
<input name="name" type="text" id="name" size="50"/>
<br />
<span class="response2">*</span>Your contact number is:<br />
<input name="telnum" type="text" id="telnum" size="20" onkeypress="return numbersonly(this, event)"/>
<br />
<span class="response2">*</span>Your contact email is:<br />
<input name="email" type="text" id="email" size="50"/>
<br />
</p>
</div>
<div id="entry">
<p class="featured_text"><span class="response2">*</span>Which Banded service interests you:<br />
<select name="service">
<option>Website</option>
<option>Logo</option>
<option>T-Shirt</option>
<option>Web Graphic</option>
<option>Posters/Flyers/Leaflets</option>
<option>Banner</option>
<option>Cover Art</option>
<option>Music Video</option>
<option>Stickers</option>
<option>Speciality (other)</option>
</select>
<input name="service_option_1" type="hidden" id="service" value="Website"/>
<input name="service_option_2" type="hidden" id="service" value="Logo"/>
<input name="service_option_3" type="hidden" id="service" value="T-Shirt"/>
<input name="service_option_4" type="hidden" id="service" value="Web Graphic"/>
<input name="service_option_5" type="hidden" id="service" value="Leaf"/>
<input name="service_option_6" type="hidden" id="service" value="Banner"/>
<input name="service_option_7" type="hidden" id="service" value="Cover Art"/>
<input name="service_option_8" type="hidden" id="service" value="Music Video"/>
<input name="service_option_9" type="hidden" id="service" value="Stickers"/>
<input name="service_option_10" type="hidden" id="service" value="Speciality"/>
<br />
If you selected &quot;Speciality&quot; please specify:<br />
<textarea name="specialityspecify"onkeydown="limitText(this.form.specialityspecify,this.form.countdown,25);"
onkeyup="limitText(this.form.specialityspecify,this.form.countdown,25);" cols="2" rows="2"></textarea>
<br />
<br />
</p>
<p class="featured_text"> Please read the <a href="tnc.html">Terms and Conditions</a> before submitting your project.<br />
<br />
<input type="checkbox" name="accept" id="accept_0" class="radio"/>
<span class="response2">*</span>I accept the terms and conditions <br />
<br />
Please ensure you have completed all fields marked with <span class="response2">*</span> </p>
<input type="submit" name="submit" id="submit" class="button" value="Submit your project"/>
</div>
</form>
<?php } else { ?>
<p>Display something else</p>
<?php } ?>


It looks weird, but it will still treat the html as being part of the if. Give it a go

andidas311
08-13-2009, 05:52 AM
Ok man this is beginning to work. From the page http://www.banded.co.uk/signupnew.html there is now a single form field - depending on which answer is chosen the rest of the form loads in place on the page action.php

What's happening though is that the 'else' portion of the code seems to be being ignored (in both IE and FF), and it's always loading the 'if' statement as true - the second version of the form associated with the 'else' statement doesn't appear.

Have I botched the code somewhere?

<h1>Entry Form</h1>

<a name="join" id="join"></a>

<?php
if ($_GET['client']=="band" || "musician" || "singer_songwriter" || "solo_artist" || "audio_artist" || "mc" || "dj"){ ?>
<form method="post" action="sendmail.php">
<div id="entry1">
<p class="featured_text">
<span class="response2">*</span>You are a:<br />
<select name="client" id="client">
<option>Please Select</option>
<option>Band</option>
<option>Musician</option>
<option>Singer/Songwriter</option>
<option>Solo Artist</option>
<option>Audio Artist</option>
<option>MC</option>
<option>DJ</option>
<option>Other</option>


</select>
<br />
If you selected &quot;Other&quot; please specify:<br />
<textarea name="otherspecify"onkeydown="limitText(this.form.otherspecify,this.form.countdown,25);"
onkeyup="limitText(this.form.otherspecify,this.form.countdown,25);" cols="2" rows="2"></textarea>
<br />
<span class="response2">*</span>Your Performing title:<br />
<input name="title" type="text" id="title"/>
<br /><span class="response2">*</span>You make this sound:<br />
<input name="sound" type="text" id="sound" size="50"/>
<br /><br /><br /><span class="response2">*</span>Your first name is:<br />
<input name="name" type="text" id="name" size="50"/>
<br /><span class="response2">*</span>Your contact number is:<br />
<input name="telnum" type="text" id="telnum" size="20" onkeypress="return numbersonly(this, event)"/>
<br /><span class="response2">*</span>Your contact email is:<br />
<input name="email" type="text" id="email" size="50"/>
<br />
</p>
</div>
<div id="entry">
<p class="featured_text"><span class="response2">*</span>Which Banded service interests you:<br />
<select name="service">
<option>Website</option>
<option>Logo</option>
<option>T-Shirt</option>
<option>Web Graphic</option>
<option>Posters/Flyers/Leaflets</option>
<option>Banner</option>
<option>Cover Art</option>
<option>Music Video</option>
<option>Stickers</option>
<option>Speciality (other)</option>

</select>
<input name="service_option_1" type="hidden" id="service" value="Website"/>
<input name="service_option_2" type="hidden" id="service" value="Logo"/>
<input name="service_option_3" type="hidden" id="service" value="T-Shirt"/>
<input name="service_option_4" type="hidden" id="service" value="Web Graphic"/>
<input name="service_option_5" type="hidden" id="service" value="Leaf"/>
<input name="service_option_6" type="hidden" id="service" value="Banner"/>
<input name="service_option_7" type="hidden" id="service" value="Cover Art"/>
<input name="service_option_8" type="hidden" id="service" value="Music Video"/>
<input name="service_option_9" type="hidden" id="service" value="Stickers"/>
<input name="service_option_10" type="hidden" id="service" value="Speciality"/>

<br />
If you selected &quot;Speciality&quot; please specify:<br />
<textarea name="specialityspecify"onkeydown="limitText(this.form.specialityspecify,this.form.countdown,25);"
onkeyup="limitText(this.form.specialityspecify,this.form.countdown,25);" cols="2" rows="2"></textarea><br /><br />

</p>
<p class="featured_text"> Please read the <a href="tnc.html">Terms and Conditions</a> before submitting your project.<br />
<br />
<input type="checkbox" name="accept" id="accept_0" class="radio"/><span class="response2">*</span>I accept the terms and conditions

<br /><br />
Please ensure you have completed all fields marked with <span class="response2">*</span> </p>
<input type="submit" name="submit" id="submit" class="button" value="Submit your project"/>



</div>
</form>
<?php } else { ?>
<form method="post" action="sendmail.php">
<div id="entry1">
<p class="featured_text">
<span class="response2">*</span>You are a:<br />
<select name="client" id="client">
<option>Please Select</option>
<option>Venue</option>
<option>Live Music Event</option>
<option>Record Label</option>
<option>Clothing Label</option>
<option>Radio Station</option>

<option>Other</option>


</select>
<br />
If you selected &quot;Other&quot; please specify:<br />
<textarea name="otherspecify"onkeydown="limitText(this.form.otherspecify,this.form.countdown,25);"
onkeyup="limitText(this.form.otherspecify,this.form.countdown,25);" cols="2" rows="2"></textarea>
<br />
<span class="response2">*</span>Your Venue/Organisation title:<br />
<input name="title" type="text" id="title"/>
<br /><span class="response2">*</span>You host this sound:<br />
<input name="sound" type="text" id="sound" size="50"/>
<br /><br /><br /><span class="response2">*</span>Your first name is:<br />
<input name="name" type="text" id="name" size="50"/>
<br /><span class="response2">*</span>Your contact number is:<br />
<input name="telnum" type="text" id="telnum" size="20" onkeypress="return numbersonly(this, event)"/>
<br /><span class="response2">*</span>Your contact email is:<br />
<input name="email" type="text" id="email" size="50"/>
<br />
</p>
</div>
<div id="entry">
<p class="featured_text"><span class="response2">*</span>Which Banded service interests you:<br />
<select name="service">
<option>Website</option>
<option>Logo</option>
<option>T-Shirt</option>
<option>Web Graphic</option>
<option>Posters/Flyers/Leaflets</option>
<option>Banner</option>
<option>Cover Art</option>
<option>Music Video</option>
<option>Stickers</option>
<option>Speciality (other)</option>

</select>
<input name="service_option_1" type="hidden" id="service" value="Website"/>
<input name="service_option_2" type="hidden" id="service" value="Logo"/>
<input name="service_option_3" type="hidden" id="service" value="T-Shirt"/>
<input name="service_option_4" type="hidden" id="service" value="Web Graphic"/>
<input name="service_option_5" type="hidden" id="service" value="Leaf"/>
<input name="service_option_6" type="hidden" id="service" value="Banner"/>
<input name="service_option_7" type="hidden" id="service" value="Cover Art"/>
<input name="service_option_8" type="hidden" id="service" value="Music Video"/>
<input name="service_option_9" type="hidden" id="service" value="Stickers"/>
<input name="service_option_10" type="hidden" id="service" value="Speciality"/>

<br />
If you selected &quot;Speciality&quot; please specify:<br />
<textarea name="specialityspecify"onkeydown="limitText(this.form.specialityspecify,this.form.countdown,25);"
onkeyup="limitText(this.form.specialityspecify,this.form.countdown,25);" cols="2" rows="2"></textarea><br /><br />

</p>
<p class="featured_text"> Please read the <a href="tnc.html">Terms and Conditions</a> before submitting your project.<br />
<br />
<input type="checkbox" name="accept" id="accept_0" class="radio"/><span class="response2">*</span>I accept the terms and conditions

<br /><br />
Please ensure you have completed all fields marked with <span class="response2">*</span> </p>
<input type="submit" name="submit" id="submit" class="button" value="Submit your project"/>



</div>
</form>
<?php } ?>

peachskittle
08-13-2009, 10:47 AM
Yes, the conditionals in your if can't be like that, they aren't attached to your first condition, each of those has to be independent. you have to tell it "if client is this" OR "if client is this" OR "if client is this"

not "if client is this" OR "This" OR "this". Because the "this" will always be true. And if any 1 of your or conditions is true, the if is true and it will never hit your else.

andidas311
08-13-2009, 12:22 PM
Ok I've removed all conditionals from the if statement and created them individually with the entire html block repeated again and again for each one, starting with if, then a bunch of else ifs and finally the else

The else ifs really did not want to work, so I changed them back to ifs.

The last problem I encountered was that each time I began a new if, I needed to add a closing } just after the <?php tag, which I reckon was closing the if statement from the html block before it.

So all in all the script works and everything is great now. Thank you so much for your time and advice, you are actually a don. Is there some sort of way I can give you feedback or big you up officially on this forum somewhere?

peachskittle
08-13-2009, 02:32 PM
Ok I've removed all conditionals from the if statement and created them individually with the entire html block repeated again and again for each one, starting with if, then a bunch of else ifs and finally the else

The else ifs really did not want to work, so I changed them back to ifs.


AHHHH No no I'm sorry I was not clear. You don't need to do that. But you do need to make a comparison for each of your conditionals. Originally, you had

if ($_GET['client']=="band" || "musician" || "singer_songwriter" || "solo_artist" || "audio_artist" || "mc" || "dj"){ ?>

But only the first conditional

$_GET['client']=="band"

will be tested. The rest of them: "musician" and "singer_songwrier", aren't actually being tested for anything, they simply exist, and mess up the if

So you can do:

if (($_GET['client']=="band") || ($_GET['client']=="musician") || ($_GET['client']=="singer_songwriter") || ($_GET['client']=="solo_artist") || ($_GET['client']=="audio_artist") || ($_GET['client']=="mc") || ($_GET['client']=="dj")){ ?>

It should do. Im not sure if there is a shorthand for this. or a shorter way. that Im not too familiar with But you should only need that HTML chunk once.

Maybe this might help fix the if else as well.

What's a don? :) And I'm happy to help! I'm not great with PHP, only as far as a front end person gets exposure to but when i can, i'm happy to assist. I don't know about any rep system, but Im not fussed, I ask my fair share of questions on this form and am happy to do what I can to give back :)

andidas311
08-14-2009, 04:15 AM
Ah ok I see what you mean about the conditionals now - I thought there might be a way to group them like that for each statement, I just didn't know the syntax. For now I reckon I'll keep them all as individual statements as over time the blocks of html that need to appear might all need to be different from one another - and currently the script works, so if it ain't broke...

Thanks again for all your help, I couldn't have done this without you.

peachskittle
08-14-2009, 08:44 AM
Anytime :) I guess you should mark as resolved if you're all set. Somehow this thread has managed 560 hits... :eek: