imimin Posted May 11, 2009 Share Posted May 11, 2009 When I try this: <?php $item_selected_style = $_GET['item_selected_style']; echo "Garment Style:"; <SELECT NAME=custom10 SIZE=1>; echo "<OPTION SELECTED="SELECTED" VALUE="$item_selected_style">"$item_selected_style"</OPTION> <OPTION VALUE="Goucho Pants w/Elastic Waist">Goucho Pants w/Elastic Waist</OPTION> <OPTION VALUE="Goucho Pants w/Draw String">Goucho Pants w/Draw String</OPTION> <OPTION VALUE="Poncho w/Hood">Poncho w/Hood</OPTION> <OPTION VALUE="Poncho without Hood">Poncho without Hood</OPTION> <OPTION VALUE="Baby Bunting">Baby Bunting</OPTION> <OPTION VALUE="Romper">Romper</OPTION>"; </SELECT><BR>; ?> It does NOT work. I get the following error: Parse error: syntax error, unexpected '<' in /homepages/27/d120150310/htdocs/poj/poj_order_form.php on line 69 Can one or more of you phpFreaks help please? Thank you! Quote Link to comment https://forums.phpfreaks.com/topic/157703-passing-variable-to-option-value-statement/ Share on other sites More sharing options...
Maq Posted May 11, 2009 Share Posted May 11, 2009 ; This is not pure PHP code. You have to echo it out like the rest of the HTML. And use single quotes around attribute values, or else it things you're ending the string. The PHP vars will still interpolate. Quote Link to comment https://forums.phpfreaks.com/topic/157703-passing-variable-to-option-value-statement/#findComment-831676 Share on other sites More sharing options...
imimin Posted May 11, 2009 Author Share Posted May 11, 2009 Thank you! That did help! Quote Link to comment https://forums.phpfreaks.com/topic/157703-passing-variable-to-option-value-statement/#findComment-831687 Share on other sites More sharing options...
Maq Posted May 11, 2009 Share Posted May 11, 2009 Thank you! That did help! Does that mean everything is working now? Quote Link to comment https://forums.phpfreaks.com/topic/157703-passing-variable-to-option-value-statement/#findComment-831694 Share on other sites More sharing options...
imimin Posted May 29, 2009 Author Share Posted May 29, 2009 Thank you so much for all of your help! The MAIN thing I need help with at this point is a php script that when I pass the value of '$item_selected_color', it will do the following: display the passed value of '$item_selected_color' as the initial SELECTED value in the dropdown list AND displaying the the image of the SELECTED value. The user can select a different color from the dropdown list and when he does, the image will change displaying an image of the users newly selected choice of color. I am doing something similar to that now with the following code(JS, HTML and php), but it does not GET the '$item_selected_color' value and therefore does not put the desired initial SELECTED value in the dropdown list and/or does not display the correct image: <SCRIPT LANGUAGE="javascript"> GarmentColorArray = new Array (; GarmentColorArray[1] = "POJ00215.jpg"; GarmentColorArray[2] = "POJ00216.jpg"; GarmentColorArray[3] = "POJ00217.jpg"; GarmentColorArray[4] = "POJ00218.jpg"; GarmentColorArray[5] = "POJ00219.jpg"; GarmentColorArray[6] = "POJ00220.jpg"; GarmentColorArray[7] = "POJ00221.jpg"; GarmentColorArray[8] = "POJ00222.jpg"; function GarmentColorImageSwap(imgBase,imgIndex) { Index = imgIndex + 1; document.GarmentColorImage.src = '/images/thumbs/' + GarmentColorArray[index]; } </SCRIPT> <!-- Garment Color = custom20--> <SELECT NAME="custom20" ONCHANGE="GarmentColorImageSwap('GarmentColorImage', this.selectedIndex)" SIZE="1"> <OPTION SELECTED="SELECTED" VALUE="test">test</OPTION> <OPTION VALUE="Color: RED Hibiscus">RED Hibiscus</OPTION> <OPTION VALUE="Color: Dark Blue Hibiscus">Dark Blue Hibiscus</OPTION> <OPTION VALUE="Color: Turquoise Hibiscus">Turquoise Hibiscus</OPTION> <OPTION VALUE="Color: Purple Hibiscus">Purple Hibiscus</OPTION> <OPTION VALUE="Color: White">White</OPTION> <OPTION VALUE="Color: American Flag">American Flag</OPTION> <OPTION VALUE="Color: Hundred Dollar Bill">Hundred Dollar Bill</OPTION> </SELECT> I would like to do something similar with a php script bypassing the JavaScript, IF POSSIBLE. Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/157703-passing-variable-to-option-value-statement/#findComment-845229 Share on other sites More sharing options...
imimin Posted June 4, 2009 Author Share Posted June 4, 2009 Can anyone help me out here? Quote Link to comment https://forums.phpfreaks.com/topic/157703-passing-variable-to-option-value-statement/#findComment-849301 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.