CrazyEngineers Forum

Turn The Screws!

Open your eyes, look in front, look at the back, look at any angle and you will see something that is an engineer's creation.

Engineers have been making things possible that others could only imagine. It perfectly makes sense to have a common place for engineers from around the world where they can share ideas, innovate, & help each other. Engineers are eternal, with the younger at 62 & the youngest at 17, the CEan gang consists of working professionals, students, entrepreneurs, CEOs, professors, geeks & nerds.

Need we say more? Click Here To Join The Gang!
Navigation
Go Back   CrazyEngineers Forum > CE : Technical Discussions > Computer Science & IT Engineering
Reply

  #1 (permalink)
Old 2nd July 2008, 09:28 PM
hbk
CE - Apprentice
 
I'm a Crazy Computers Engineer
Join Date: 12th June 2008
Posts: 36
Default drop down menu based on form input

hi...

I am developing an application using PHP/MySQL.

here, i have one page(say P1), which contains a form(just one drop down menu, say D1, with only 2 options , say O1 and O2)...

the target of P1 is another page, say P2.

Now, P2 is also a form, and contains a number of fields (all text fields)...

THE PROBLEM

P2 also contains a drop down menu.
Now, this is not a static drop down menu.

If, on P1, the user selectes O1, then a particular drop down menu is displayed on P2.(say D2)

If, on P1, the user selects O2, then another drop down menu is shown (say D3)

Both D2 and D3 are different from D1.

I have coded this, but it shows me errors. I guess i may be mixing HTML and PHP code at some place, but am unable to figure it out... pls help me out if u can...

I am posting the code i developed...


THE CODE


P1.php

Code:
<html>
<form action = "P2.php" method = "POST">

<select name = "dbase">

<option>abc</option>
<option>xyz</option>

</select>

<input type="submit" value="Enter Client Details"/>

</form>
</html>
P2.php

Code:
 <html>
<?php
$db = $_POST["dbase"];
?>

<form action = "P3.php" method = "POST">

Name: <input type = "text" name = "Name">

ID: <input type="text" name="ID" />

<?php
if($_POST["dbase"] == 'abc')
{
<select name = "tests">

<option>Maths</option>
<option>English</option>

</select>
}

else
{
Test : <select name = "tests">

<option>Physics</option>
<option>Chemistry</option>
<option>Geography</option>
</select>
}

?>

<input type="submit" value="Submit"/>

</form>
</html>

please help me out...

thx...
__________________
2 ways to happines--->

1. Accept what you cannot change
2, Change what you cannot accept

Last edited by The_Big_K : 2nd July 2008 at 09:31 PM.
hbk is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored links
  #2 (permalink)
Old 2nd July 2008, 09:32 PM
hbk
CE - Apprentice
 
I'm a Crazy Computers Engineer
Join Date: 12th June 2008
Posts: 36
Default Re: drop down menu based on form input

one possible solution to this is:

If on P1, the user selects O1, i direct him to page Pa.php, which contains the drop down menu D2.

Instead, If on P1, the user selects O2, i direct him to page Pb.php, which contains the drop down menu D3.

though this is a possible solution, it also involves a problem.

Here, i will have to dynamically decide the target of my page P1, depending on whether the user chooses O1 or O2.

I have searched this. It is possible using javascript, but i havent found a solution to this using PHP.

So if anybody could please explani this, i would be really grateful...

thx a ton ...
__________________
2 ways to happines--->

1. Accept what you cannot change
2, Change what you cannot accept
hbk is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored links
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +5.5. The time now is 06:03 PM.
Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Member comments are owned by the poster. Copyright © 2005-2008 CrazyEngineers.com. All rights reserved.Ad Management by RedTyger