| | |
Refresh + Combo Box
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
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.
Ignorance is definitely not bliss!
*PM asking for help will be ignored*
*PM asking for help will be ignored*
Hi nav33n, my php GURU!
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.
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
PHP Syntax (Toggle Plain Text)
<?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 $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<b></b>: 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>"; ?>
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)
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.
![]() |
Similar Threads
- How to clear or refresh a combo box? (VB.NET)
- can not update combo box... (VB.NET)
- Updating Combo Box (Visual Basic 4 / 5 / 6)
- problem in listing directories in list box (Java)
- updating DataGrid on Button Press (ASP.NET)
- Text field does not enable on refresh (JavaScript / DHTML / AJAX)
- Include datafield into the section 4 of the Datareport (Visual Basic 4 / 5 / 6)
- Fill a combobox (Visual Basic 4 / 5 / 6)
Other Threads in the PHP Forum
- Previous Thread: JPGraph+IMG TAG
- Next Thread: please help me in drop down list
Views: 4895 | Replies: 5
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array autosuggest beginner binary broken cakephp checkbox class cms code cron curl database date directory display download dynamic echo email emptydisplayvalue error explodefunction file files folder form forms function functions google hack href htaccess html image include insert integration ip java javascript joomla keywords limit link login loop mail menu methods mlm mod_rewrite multiple mysql oop parse paypal pdf php problem query radio random recursion regex remote script search searchbox select server sessions sms soap source space speed sql structure syntax system table tutorial update upload url validation validator variable video web website xml youtube







lol.. no ! I am a learner.. I am glad your problem was fixed !