marmite Posted March 20, 2007 Share Posted March 20, 2007 Hello, I am recoding a greeting card website. I am using dropdowns as filters for items in a DB, so when the user picks "animals" from the "theme" dropdown, the returned cards all feature animals, and when the user picks "birthday" from the "message" option, the returned cards all feature birthday cards. However, there are some combinations that don't return any results, for example "get well" "floral" cards. I want my dropdowns to be dynamic, so that when they click theme "floral", BEFORE they hit submit, the message "getwell" option disappears. I am struggling because I want to use javascript within PHP which of course isn't working. Does anyone know how/if I can pass the form parameter into the php? Or if there is another way of doing this? Thanks Emma (newbie) <div id="search_box"> <form action="http://localhost/New_CU/greetingscards.php" method="get" name = "filters" id="filters"> <table width="90%"> <tr> <td width="51" scope="row">Theme</td> <td scope="row"> <select name="theme" id="theme1"> <option value="All"<?php if($_GET['theme'] == "All") { echo ' selected="selected"'; } ?>>All</option> <option value="Animal"<?php if($_GET['theme'] == "Animal") { echo ' selected="selected"'; } ?>>Animal</option> <option value="Floral"<?php if($_GET['theme'] == "Floral") { echo ' selected="selected"'; } ?>>Floral</option> <option value="Leisure"<?php if($_GET['theme'] == "Leisure") { echo ' selected="selected"'; } ?>>Leisure</option> <option value="Travel"<?php if($_GET['theme'] == "Travel") { echo ' selected="selected"'; } ?>>Travel</option> </select></td> </tr> <tr> <td width="51" scope="row">Purpose</td> <td width="97" scope="row"><select name="purpose" id="purpose"> <option value="All"<?php if($_GET['purpose'] == "All") { echo ' selected="selected"'; } ?>>All</option> <option value="Personal"<?php if($_GET['purpose'] == "Personal") { echo ' selected="selected"'; } ?>>Personal</option> <option value="Invitations"<?php if($_GET['purpose'] == "Invitations") { echo ' selected="selected"'; } ?>>Invitations</option> <option value="Office"<?php if($_GET['purpose'] == "Office") { echo ' selected="selected"'; } ?>>Office</option> <option value="Retail"<?php if($_GET['purpose'] == "Retail") { echo ' selected="selected"'; } ?>>Retail</option> <option value="Wholesale"<?php if($_GET['purpose'] == "Wholesale") { echo ' selected="selected"'; } ?>>Wholesale</option> </select></td> </tr> <tr> <td width="51" scope="row">Message</td> <td scope="row"><select name="message" id="message1"> <option value="all"<?php if($_GET['message'] == "all") { echo ' selected="selected"'; } ?>>All</option> <option value="blank"<?php if($_GET['message'] == "blank") { echo ' selected="selected"'; } ?>>Blank</option> <option value="nonblank"<?php if($_GET['message'] == "nonblank") { echo ' selected="selected"'; } ?>>Non Blank</option> <option value="birthday"<?php if($_GET['message'] == "birthday") { echo ' selected="selected"'; } ?>>Birthday</option> <option value="congrats"<?php if($_GET['message'] == "congrats") { echo ' selected="selected"'; } ?>>Congratulations</option> <option value="getwell"<?php if($_GET['message'] == "getwell") { echo ' selected="selected"'; } ?>>Get Well Soon</option> <option value="thankyou"<?php if($_GET['message'] == "thankyou") { echo ' selected="selected"'; } ?>>Thank you</option> <option value="christmas"<?php if($_GET['message'] == "christmas") { echo ' selected="selected"'; } ?>>Christmas</option> </select> </td> </tr> <tr > <td colspan="2" scope="row" align="right"><input type="submit" name="submit2" value="Find cards" /></td> </tr> </table> </form> </div> Link to comment https://forums.phpfreaks.com/topic/43552-dynamic-dropdown-lists-with-php-new/ Share on other sites More sharing options...
Barand Posted March 20, 2007 Share Posted March 20, 2007 Use AJAX Sample in link in my sig Link to comment https://forums.phpfreaks.com/topic/43552-dynamic-dropdown-lists-with-php-new/#findComment-211496 Share on other sites More sharing options...
marmite Posted March 20, 2007 Author Share Posted March 20, 2007 Thanks... (I'm going to be here all night!) Link to comment https://forums.phpfreaks.com/topic/43552-dynamic-dropdown-lists-with-php-new/#findComment-211506 Share on other sites More sharing options...
marmite Posted March 20, 2007 Author Share Posted March 20, 2007 I am so confused. Can you tell me which part of your (excellent) example is relevant for me? Is there any other way of doing this? Is there a long way round that does not involve me learning all this new stuff right now (deadline looming)? Thanks Emma Link to comment https://forums.phpfreaks.com/topic/43552-dynamic-dropdown-lists-with-php-new/#findComment-211567 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.