Newbie needs help
Posted 03 April 2006 - 02:51 AM
I am building a webpage with cell phone and accessories ads. Basically when someone wants to sell his/her cell phone will post an ad on my webpage.
I want to create a list/menu with the 3 categories (phones, accessories, cards), and pass the 3 values to category.php page.
Here's the code for the list/menu so far which is contained in the choose.php file:
echo "<select name='category'>\n";
echo "<option name='category' value='phones'>Phones</option>\n";
echo "<option name='category' value='accessories'>Accessories</option>\n";
echo "<option name='category' value='cards'>Cards</option>\n";
The query for the category.php page looks like this:
$query = "SELECT * FROM ad WHERE (and I want the value passed from the list/menu in here)"
I would also like to mention that the list/menu should have a onChange auction (I do not want a submit button) and it should take you to category.php page(this is also the page where the values should be passed to).
Thank you in advance.
Posted 03 April 2006 - 08:48 AM
hopfully this helps if it doesn't sorry
i won't write the code for you!!! you don't learn that way
Posted 03 April 2006 - 08:58 AM
echo "<form name=\"cat\" action=\"category.php\" method=\"get\">"; echo "<select name=\"cat\" onChange=\"document.cat.submit()\">\n"; echo "<option>Choose a category:</option>\n"; echo "<option value=\"phones\">Phones</option>\n"; echo "<option value=\"accessories\">Accessories</option>\n"; echo "<option value=\"cards\">Cards</option>\n"; echo "</select>"; echo "</form>"Now when the user selects a category they will be sent to category.php. Now to retieve the sent data you'll want to use this code:
document.cat.submit(); to submit the form with the onChange event! Then if you read the comments (//) in the secound code block you should see how it's done.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users