Click to See Complete Forum and Search --> : Drop down Menu's Form -- Multiple Options (need PHP form for submit)
GreyFaerie
10-04-2003, 01:18 PM
Im sorry if the subject didnt explain this well... but in so little words i couldnt find a better way to do it. Basically what I want to do is on this page :
Neoitems.net ... its to the very right in the second block where it says 'pet colors'. Two drop downs, one submit, and i want the image to show up by the form. I know how to make the form and how to link it up to the PHP documnet... I just don't know what PHP form I need to use to accomplish this. Hopefully I have explained this well enough... if i havent please let me know and I will try and go into better detail. If there is a site you can give me that shows what form to use or how to make one that will do just fine...
Thanks so much!!
PunkSktBrdr01
10-04-2003, 02:59 PM
Do you mean you want to dynamically generate an image based on the form input? This would be really hard, but it might be possible. Or maybe not. Lemme know if that's what you want.
GreyFaerie
10-04-2003, 11:33 PM
i want exactly what is on the site i posted... i will prolly have the image show up to the right though
First, you have to make all the images you want to use in all the colors you want to be selectable. Then when a user submits the form, lets say he has selected "Acara" and "Baby", the php-script shows the image "acara_baby_happy.gif".
GreyFaerie
10-05-2003, 10:41 AM
that helps... but i dont know how to write the script at all :( should i just give up ? I have all the images and everything... so basically im set i just need the php
You just need a few lines of code.
In this example I have a circle and a square in 3 different colors.
1.Set up the form:
<form method="post" action="index.php">
<select name="object">
<option value="circle" >Circle</option>
<option value="square">Square</option>
</select><br>
<select name="color">
<option value="red" >Red</option>
<option value="blue">Blue</option>
<option value="green" >Green</option>
</select>
<input type="hidden" name="submitted" value="1">
<input type="submit" value="Go!">
</form>
2. The php code:
<?php
// The folder with all the images in
$folder = "images/";
if(isset($_POST["submitted"])) {
print("<img src=\"".$folder.$_POST["object"]."_".$_POST["color"].".gif\">");
}
?>
Now, if I had selected a red circle, it would show an image called images/circle_red.gif
GreyFaerie
10-06-2003, 03:10 PM
wow thanks!! that helps out sooooo much. thanks for your time!
GreyFaerie
10-06-2003, 03:43 PM
Ok... i will have two drop downs in the form with select names "Pet" and "Colour".
Then all the file names have this basic format for their file name:
pet_colour_happy.gif
The 'pet' and 'colour' parts of the file name change (with the php code) while the 'happy' part stays the same.
and ex: (blumaroo, kacheek, and acara are pets)
blumaroo_brown_happy.gif
kacheek_green_happy.gif
acara_blue_happy.gif
so what im asking is how do i get the 'happy' into the php code? everyting is perfect in the first one you gave me... i just need to find a way to get that last part of the file name in there
hopefully I explained this well..
PunkSktBrdr01
10-06-2003, 07:05 PM
Add a new select list for the moods, and in the PHP code, replace
print("<img src=\"".$folder.$_POST["object"]."_".$_POST["color"]."_".$_POST["mood"].".gif\">");
GreyFaerie
10-06-2003, 09:59 PM
ok... im doing something wrong. if you could help me I would be ever so greatful....
This is the form on a page i named PetColours.htm ...
<div align="center">
<form method="post" action="/petcolours.php">
<select name="Pet" id="Pet">
<option value="acara">Acara</option>
<option value="aisha">Aisha</option>
</select>
<SELECT NAME="colour">
<option value="red">Red </option>
<option value="green">Green </option>
</SELECT>
<br>
<br>
<input type="submit" name="Go!" value="Go!">
<br>
<br>
</form>
</div>
Here is the PHP file ...
<?php
// The folder with all the images in
$folder = "http://images.neopets.com/pets/happy/";
if(isset($_POST["submitted"])) {
print("<img src=\"".$folder.$_POST["Pet"]."_".$_POST["Colour"]."_baby".".gif\">");
}
?>
PunkSktBrdr01
10-06-2003, 10:37 PM
In PetColours.htm, change the name of the submit button to "submitted".
GreyFaerie
10-07-2003, 05:32 AM
its just sending me to a blank page.... goto www.playingwithfaeries.com/PetColours.htm to see what im talking about
Have you changed this line like PunkSktBrdr01 said?
<input type="submit" name="Go!" value="Go!">
to
<input type="submit" name="submitted" value="Go!">
PunkSktBrdr01
10-07-2003, 02:56 PM
Okay, I found the problem. You still have the name for the submit button wrong. It needs to be "submitted" all in lowercase. PHP variables are case sensetive, so "Submitted" (what you have) is not the same as "submitted". It's a simple mistake, but it prevents the script from working.
GreyFaerie
10-07-2003, 03:42 PM
thanks so much for your help... and yes it works now. but i guess im getting myself into more trouble... becuase i want the image to show up to the right of the image. Ive updated the page to what i am trying to do so you can take a look. i decided maybe using an iframe would work... if there is a better way please let me know. anyway... when the fram first opens up the image i have linked to it works but when you try to submit the form i get a 'page cannot be displayed' in the iframe. here is what i got and i havent changed anything in the php file..
I linked the form to load in the iframe :
<form method="post" action="/petcolours.php" target="images">
<select name="Pet" id="Pet">
<option value="acara">Acara</option>
<option value="aisha">Aisha</option>
....
And here is the code i used for the iframe:
<iframe src="http://images.neopets.com/pets/happy/kacheek_yellow_baby.gif" scrolling="no" name="images" width="160" height="170" frameborder="0">
</iframe>
Can you please help? thanks so much to all of you... for your time and your extertise. I greatly appreciate it
PunkSktBrdr01
10-07-2003, 04:59 PM
Looks good! It's working fine for me. I'm using Mozilla Firebird 0.6.1.
GreyFaerie
10-07-2003, 09:24 PM
oh wow... so it is! lol... i dont know what i did but i obviously did something right... lol. but all i know is that i couldnt have done it without you... thanks so much :)