943,929 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 12084
  • PHP RSS
May 8th, 2008
0

Refresh + Combo Box

Expand Post »
Pretty simple, just dont know how to find the solution XS.

I have a combo box, that once u select the required attribute (A, B, C).

It should display the apporiate text of A, B, C below it.

So any ideas?

Thanks, Regards X
Similar Threads
Reputation Points: 31
Solved Threads: 10
Practically a Master Poster
OmniX is offline Offline
652 posts
since Dec 2007
May 8th, 2008
0

Re: Refresh + Combo Box

you can using this:
$_POST['dropdown list name'];
if this not true please give me more explains.
Reputation Points: 10
Solved Threads: 0
Light Poster
almualim is offline Offline
28 posts
since May 2008
May 8th, 2008
1

Re: Refresh + Combo Box

I said it in the other thread, have an onchange event to submit the page when you select a value from the dropdown list. When the page is submitted, you can know which option was selected from the dropdown list. ($val = $_POST['dropdownlistname']; ) Then query the table with this value as condition and retrieve the data.
Moderator
Featured Poster
Reputation Points: 524
Solved Threads: 356
Purple hazed!
nav33n is offline Offline
3,878 posts
since Nov 2007
May 8th, 2008
0

Re: Refresh + Combo Box

Hi nav33n, my php GURU!

PHP Syntax (Toggle Plain Text)
  1. <?php $con = mysql_connect("localhost","root"); mysql_select_db("test"); $query = "select col1 from table"; $result = mysql_query($query); echo "<form method='post' action='test.php'>"; echo "<select name=dropdown1 onchange='javascript: document.form.submit();'>"; while($row = mysql_fetch_array($result)) { $value = $row['col1']; echo "<option value='".$value."'>$value</option>"; } echo "</select>"; $firstdropdownlistvalue = $_POST['dropdown1']; $query2 = "select * from table where col2 = '$firstdropdownlistvalue'"; $result2 = mysql_query($query2); echo "<select name=dropdown2>"; while($row2 = mysql_fetch_array($result2)) { $value2 = $row2['col1']; echo "<option value='".$value2."'>$value2</option>"; } echo "</select>"; echo "</form>";?><?php
  2. $con = mysql_connect("localhost","root");
  3. mysql_select_db("test");
  4. $query = "select col1 from table";
  5. $result = mysql_query($query);
  6. echo "<form method='post' action='test.php'>";
  7. echo "<select name=dropdown1 onchange='javascript<b></b>: document.form.submit();'>";
  8. while($row = mysql_fetch_array($result)) {
  9. $value = $row['col1'];
  10. echo "<option value='".$value."'>$value</option>";
  11. }
  12. echo "</select>";
  13.  
  14. $firstdropdownlistvalue = $_POST['dropdown1'];
  15. $query2 = "select * from table where col2 = '$firstdropdownlistvalue'";
  16. $result2 = mysql_query($query2);
  17. echo "<select name=dropdown2>";
  18. while($row2 = mysql_fetch_array($result2)) {
  19. $value2 = $row2['col1'];
  20. echo "<option value='".$value2."'>$value2</option>";
  21. }
  22. echo "</select>";
  23. echo "</form>";
  24. ?>

From your other thread a few questions, as mine is linked to a mysql database which the values are retrieved from that.

I have pretty much everything you have there already minus the on change even like you said.

PHP Syntax (Toggle Plain Text)
  1. echo "<select name=dropdown1 onchange='javascript: document.form.submit();'>";

So this is the only code I need to add to let my form submit itself and show the appropriate data?

Also another quick Q, once I have selected the drop down item and refreshed the page, I wish to keep the selected item in the combo box and not be reset to the intial value.Any ideas?

Thanks for all your help again, ill try that now. - I just tested it and it works BUT my first drop down isnt refreshing but my second is =S (Ill go debug and keep you posted)

Regards, X
Last edited by OmniX; May 8th, 2008 at 9:31 pm.
Reputation Points: 31
Solved Threads: 10
Practically a Master Poster
OmniX is offline Offline
652 posts
since Dec 2007
May 8th, 2008
0

Re: Refresh + Combo Box

After a whole bunch of debugging everything is done!
Thanks nav once again your a legend
Reputation Points: 31
Solved Threads: 10
Practically a Master Poster
OmniX is offline Offline
652 posts
since Dec 2007
May 9th, 2008
0

Re: Refresh + Combo Box

lol.. no ! I am a learner.. I am glad your problem was fixed !
Moderator
Featured Poster
Reputation Points: 524
Solved Threads: 356
Purple hazed!
nav33n is offline Offline
3,878 posts
since Nov 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: JPGraph+IMG TAG
Next Thread in PHP Forum Timeline: please help me in drop down list





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC