943,712 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 8823
  • PHP RSS
Sep 9th, 2008
0

php combobox

Expand Post »
i have two combox in my page.first is for division and second for gp.when user selecte division corresponding value shoud me fill from mysql in second combox with out submit my form data.any help..

from rohit
Last edited by rohitrohitrohit; Sep 9th, 2008 at 7:44 am.
Similar Threads
Reputation Points: 15
Solved Threads: 5
Junior Poster
rohitrohitrohit is offline Offline
120 posts
since Oct 2007
Sep 9th, 2008
0

Re: php combobox

you can get good solutions here:
http://www.daniweb.com/forums/thread132703.html
Reputation Points: 137
Solved Threads: 162
Posting Virtuoso
Shanti C is offline Offline
1,641 posts
since Jul 2008
Sep 9th, 2008
0

Re: php combobox

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)
  1. <?
  2. $res_c=mysql_query("select * from dbtable where parentid=0 and status=1");
  3. echo "<script language=javascript>\n";
  4. echo "function chgselcat() {\n";
  5. echo "var d=document.reg_form;\n";
  6. echo "if(d.cat.value==0) {\n";
  7. echo "d.subcat.options.length = 0;\n";
  8. echo "d.subcat.options[0]=new Option(\"Select \",\"\")\n";
  9. echo "}\n";
  10. while($row_c=mysql_fetch_array($res_c,MYSQL_BOTH)){
  11. echo "if(d.cat.value==".$row_c['ad_cid'].") {\n";
  12. echo "d.subcat.length=0;\n";
  13. $sub_res=mysql_query("SELECT * from dbtable where parentid=".$row_c['ad_cid']." and status=1 order by catname ");
  14. $i=1;
  15. echo "d.subcat.options[0]=new Option(\"--Select Sub Category-- \",\"\")\n";
  16. while($sub_row=mysql_fetch_array($sub_res,MYSQL_BOTH)){
  17. echo "d.subcat.options[".$i."]=new Option('".$sub_row['ads_catname']."','".$sub_row['ad_cid']."');\n";
  18. $i=$i+1;
  19. }
  20. echo "}\n";
  21. }
  22. echo "}</script>\n";
  23. ?>
Reputation Points: 21
Solved Threads: 29
Posting Whiz in Training
praveen_dusari is offline Offline
202 posts
since Jun 2008
Sep 9th, 2008
0

Re: php combobox

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
Reputation Points: 30
Solved Threads: 36
Posting Whiz
langsor is offline Offline
389 posts
since Aug 2008

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: regarding rewriting a page
Next Thread in PHP Forum Timeline: list menu pass result





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


Follow us on Twitter


© 2011 DaniWeb® LLC