Vinodpv Posted April 22, 2014 Share Posted April 22, 2014 Connected DropDown List working in Local host not in online-- Please help me any one <script type="text/javascript" src="js/jquery-1.7.1.min.js"></script> <script type="text/javascript" src="js/jquery-ui-1.8.17.custom.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $('.userAddress').change(function(){ var company=$('.userAddress').val(); $.ajax({ type:"post", url:"branch.php", data:"company="+company, success:function(data){ $("#branch").html(data); } }); }); </script> <?php $queryComp = mysql_query("SELECT comp_name FROM company"); ?> <tr> <td width="125">Company</td> <td width="10">:</td> <td><select name="company" id="company" style="background:#DFDFFF" class="validate[required] userAddress"> <option>-select your company-</option> <?php include "db_conexn.php"; $result=mysql_query("SELECT comp_name from company order by comp_name"); while($company=mysql_fetch_array($result)){ echo "<option value=$company[comp_name]>$company[comp_name]</option>"; } ?> </select> </td></tr> <tr><td>Branch </td><td>:</td> <td> <select name="branch" id="branch" style="background:#DFDFFF"> <option>-select your branch-</option> </select> </td> </tr>branch.php <?php include "db_conexn.php"; $company=$_POST["company"]; $result=mysql_query("select branch,comp_name FROM branch where comp_name='$company' "); while($branch=mysql_fetch_array($result)){ echo"<option value=$branch[branch]>$branch[branch]</option>"; }?> Quote Link to comment https://forums.phpfreaks.com/topic/287944-connected-dropdown-list/ Share on other sites More sharing options...
davidannis Posted April 22, 2014 Share Posted April 22, 2014 Do you get any messages? Is the javascript actually working? Try putting an alert or two in the javascript to see where it fails: <script type="text/javascript"> $(document).ready(function(){ $('.userAddress').change(function(){ var company=$('.userAddress').val(); alert (company); $.ajax({ type:"post", url:"branch.php", data:"company="+company, success:function(data){ alert (data); $("#branch").html(data); } }); }); </script> Quote Link to comment https://forums.phpfreaks.com/topic/287944-connected-dropdown-list/#findComment-1476982 Share on other sites More sharing options...
bsmither Posted April 22, 2014 Share Posted April 22, 2014 Is validate[required] a valid class attribute? Quote Link to comment https://forums.phpfreaks.com/topic/287944-connected-dropdown-list/#findComment-1476984 Share on other sites More sharing options...
Vinodpv Posted April 22, 2014 Author Share Posted April 22, 2014 Hi Friends, Here the problem getting like, if I have more than one elements in branch its working. (Display Branches while selecting Company) but if only one branch its coming blank in branch list Please help....I take ......lot of time ... cant find where is the mistake Quote Link to comment https://forums.phpfreaks.com/topic/287944-connected-dropdown-list/#findComment-1476992 Share on other sites More sharing options...
Vinodpv Posted April 22, 2014 Author Share Posted April 22, 2014 Can u please help me to do this. Y the second drop down box not showing element, if it is one. Onlly the multiple elements are shows in branch Quote Link to comment https://forums.phpfreaks.com/topic/287944-connected-dropdown-list/#findComment-1476994 Share on other sites More sharing options...
davidannis Posted April 22, 2014 Share Posted April 22, 2014 If you put an alert in the javascript as suggested do you get a window that shows the option code? If not, try accessing branch.php directly and see what you get. Also, please sanitize your input with mysql_real_escape_ string and consider mysqli instead of mysql. Quote Link to comment https://forums.phpfreaks.com/topic/287944-connected-dropdown-list/#findComment-1477017 Share on other sites More sharing options...
Vinodpv Posted April 23, 2014 Author Share Posted April 23, 2014 Hi Freind, Yes getting alert box the values, but incase of one element in the branch(2nd dropdown) in alert box no values, Y like this? If u need I will send full code.. PLEASE HELP ME.. Quote Link to comment https://forums.phpfreaks.com/topic/287944-connected-dropdown-list/#findComment-1477042 Share on other sites More sharing options...
Solution davidannis Posted April 24, 2014 Solution Share Posted April 24, 2014 Try to echo the query in branch. Php and execute it in phpmysql directly. I think the problem may be with your data Quote Link to comment https://forums.phpfreaks.com/topic/287944-connected-dropdown-list/#findComment-1477181 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.