Advertisement
Guest User

Untitled

a guest
Oct 6th, 2013
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.84 KB | None | 0 0
  1. <select name="supplier" id="supplier" onChange="redirect(this.options.selectedIndex)">
  2. <?php
  3. $sql="select * from suppliers order by name ASC";
  4. $rs=mysql_query($sql,$conn) or die(mysql_error());
  5. while($result=mysql_fetch_array($rs))
  6. {
  7. echo('<option value="'.$result['sequence'].'">'.$result['name'].'</option>');
  8. }
  9. ?>
  10. </select>
  11.  
  12. <select name="crmsystem" id="crmsystem">
  13. <?
  14. //get first company details only - this is a fudge for displaying purposes only
  15. $sql="select * from suppliers order by name ASC";
  16. $rs=mysql_query($sql,$conn) or die(mysql_error());
  17. $result=mysql_fetch_array($rs);
  18.  
  19. $sql="select * from crmsystems where supplier='".$result["sequence"]."' and invoice = 'yes' order by name ASC";
  20. //echo($sql);
  21. $rs=mysql_query($sql,$conn) or die(mysql_error());
  22. while($result=mysql_fetch_array($rs))
  23. {
  24. echo('<option value="'.$result['sequence'].'">'.$result['name'].'</option>');
  25. }
  26. ?>
  27.  
  28.  
  29. </select>
  30.  
  31.  
  32. <script>
  33. <!--
  34.  
  35. /*
  36. Pre-load the double combo box
  37. */
  38.  
  39. var groups=document.doublecombo.supplier.options.length
  40.  
  41. var group=new Array(groups)
  42. for (i=0; i<groups; i++)
  43. group[i]=new Array()
  44.  
  45. <?php
  46. //now the clever bit - create an array for each new company
  47. $sql="select * from suppliers order by name ASC";
  48. $rs=mysql_query($sql,$conn) or die(mysql_error());
  49. $counter=0;
  50. while($result=mysql_fetch_array($rs))
  51. {
  52. $sql2="select * from crmsystems where supplier='".$result["sequence"]."' and invoice = 'yes' order by name ASC";
  53. $rs2=mysql_query($sql2,$conn) or die(mysql_error());
  54. $counter2=0;
  55. if(mysql_num_rows($rs2)>0)
  56. {
  57. while($result2=mysql_fetch_array($rs2))
  58. {
  59. echo('group['.$counter.']['.$counter2.']=new Option("'.$result2["name"].'","'.$result2["sequence"].'"); ');
  60. $counter2++;
  61. }
  62. }
  63. else
  64. {
  65. echo('group['.$counter.'][0]=new Option("No Contact","No Contact") ;');
  66. }
  67. $counter++;
  68. }
  69. ?>
  70.  
  71.  
  72.  
  73. var temp=document.doublecombo.crmsystem
  74.  
  75. function redirect(x)
  76. {
  77. for (m=temp.options.length-1;m>0;m--)
  78. temp.options[m]=null
  79. for (i=0;i<group[x].length;i++)
  80. {
  81. temp.options[i]=new Option(group[x][i].text,group[x][i].value)
  82. }
  83. temp.options[0].selected=true
  84. }
  85.  
  86. function go(){
  87. location=temp.options[temp.selectedIndex].value
  88. }
  89. //-->
  90. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement