| | |
php combobox
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
you can get good solutions here:
http://www.daniweb.com/forums/thread132703.html
http://www.daniweb.com/forums/thread132703.html
Be intelligent, But Don't try to cheat.. Be innocent But Don't get cheated..
i didn`t understand what u exactly want, ok, if u want to update the second one depending on the first one the here is the code which uses javascript
php Syntax (Toggle Plain Text)
<? $res_c=mysql_query("select * from dbtable where parentid=0 and status=1"); echo "<script language=javascript>\n"; echo "function chgselcat() {\n"; echo "var d=document.reg_form;\n"; echo "if(d.cat.value==0) {\n"; echo "d.subcat.options.length = 0;\n"; echo "d.subcat.options[0]=new Option(\"Select \",\"\")\n"; echo "}\n"; while($row_c=mysql_fetch_array($res_c,MYSQL_BOTH)){ echo "if(d.cat.value==".$row_c['ad_cid'].") {\n"; echo "d.subcat.length=0;\n"; $sub_res=mysql_query("SELECT * from dbtable where parentid=".$row_c['ad_cid']." and status=1 order by catname "); $i=1; echo "d.subcat.options[0]=new Option(\"--Select Sub Category-- \",\"\")\n"; while($sub_row=mysql_fetch_array($sub_res,MYSQL_BOTH)){ echo "d.subcat.options[".$i."]=new Option('".$sub_row['ads_catname']."','".$sub_row['ad_cid']."');\n"; $i=$i+1; } echo "}\n"; } echo "}</script>\n"; ?>
Failure is success if we learn from it
•
•
Join Date: Aug 2008
Posts: 381
Reputation:
Solved Threads: 33
If I understand correctly ...
1. You want to load the page with the form
2. When someone selects an item in Box A
3. Box B is populated with values based on Box A's selected item
4. And not reload the page or submit the form at this time
You can not do this with PHP alone. You would need to submit the form and thus reload the page in order to just use PHP to do this.
The current standard way to do this is to use JavaScript to ...
1. Detect when a new item has been selected in Box A
2. And then make a JavaScript Asynchronous Http Request (AJAX) to a server-side script (PHP) and receive the results of that request.
3. Once the JavaScript receives the results the JavaScript then updates the values of Box B using ...
3a. innerHTML method, or
3b. DOM methods
Hope this helps, let us know if you need more help with this
1. You want to load the page with the form
2. When someone selects an item in Box A
3. Box B is populated with values based on Box A's selected item
4. And not reload the page or submit the form at this time
You can not do this with PHP alone. You would need to submit the form and thus reload the page in order to just use PHP to do this.
The current standard way to do this is to use JavaScript to ...
1. Detect when a new item has been selected in Box A
2. And then make a JavaScript Asynchronous Http Request (AJAX) to a server-side script (PHP) and receive the results of that request.
3. Once the JavaScript receives the results the JavaScript then updates the values of Box B using ...
3a. innerHTML method, or
3b. DOM methods
Hope this helps, let us know if you need more help with this
Google is the answer to all of your questions -- the trick is knowing what question to ask in your specific predicament.
![]() |
Similar Threads
- How Do I Get Value Selected From ComboBox? (VB.NET)
- inserting checkbox values in mysql +PHP (PHP)
- php and database (PHP)
- Stumped: Error on Combo Box Sort (MS Access and FileMaker Pro)
- Need some help with a comboBox control (C#)
- gtk.ComboBox (Python)
- Help with a reservation program! GUI Messed XD (Java)
Other Threads in the PHP Forum
- Previous Thread: regarding rewriting a page
- Next Thread: list menu pass result
| Thread Tools | Search this Thread |
.htaccess alerts apache api archive array autocomplete beginner binary broken cakephp checkbox class cms code convert cron curl database dataentry date display duplicates dynamic echo email emptydisplayvalue error execute explodefunction file files firstoptioninphpdroplist folder form forms function functions google hack href htaccess html htmlspecialchars image include insert ip javasciptvalidation javascript joomla keywords limit link login mail matching menu methods mlm multiple mysql network object oop paypal pdf php problem query radio random recursion recursive redirect remote script search securephp server sessions shot sms source space sql subscription syntax system table tutorial tutorials update upload url validator variable video web youtube






