Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <select name="supplier" id="supplier" onChange="redirect(this.options.selectedIndex)">
- <?php
- $sql="select * from suppliers order by name ASC";
- $rs=mysql_query($sql,$conn) or die(mysql_error());
- while($result=mysql_fetch_array($rs))
- {
- echo('<option value="'.$result['sequence'].'">'.$result['name'].'</option>');
- }
- ?>
- </select>
- <select name="crmsystem" id="crmsystem">
- <?
- //get first company details only - this is a fudge for displaying purposes only
- $sql="select * from suppliers order by name ASC";
- $rs=mysql_query($sql,$conn) or die(mysql_error());
- $result=mysql_fetch_array($rs);
- $sql="select * from crmsystems where supplier='".$result["sequence"]."' and invoice = 'yes' order by name ASC";
- //echo($sql);
- $rs=mysql_query($sql,$conn) or die(mysql_error());
- while($result=mysql_fetch_array($rs))
- {
- echo('<option value="'.$result['sequence'].'">'.$result['name'].'</option>');
- }
- ?>
- </select>
- <script>
- <!--
- /*
- Pre-load the double combo box
- */
- var groups=document.doublecombo.supplier.options.length
- var group=new Array(groups)
- for (i=0; i<groups; i++)
- group[i]=new Array()
- <?php
- //now the clever bit - create an array for each new company
- $sql="select * from suppliers order by name ASC";
- $rs=mysql_query($sql,$conn) or die(mysql_error());
- $counter=0;
- while($result=mysql_fetch_array($rs))
- {
- $sql2="select * from crmsystems where supplier='".$result["sequence"]."' and invoice = 'yes' order by name ASC";
- $rs2=mysql_query($sql2,$conn) or die(mysql_error());
- $counter2=0;
- if(mysql_num_rows($rs2)>0)
- {
- while($result2=mysql_fetch_array($rs2))
- {
- echo('group['.$counter.']['.$counter2.']=new Option("'.$result2["name"].'","'.$result2["sequence"].'"); ');
- $counter2++;
- }
- }
- else
- {
- echo('group['.$counter.'][0]=new Option("No Contact","No Contact") ;');
- }
- $counter++;
- }
- ?>
- var temp=document.doublecombo.crmsystem
- function redirect(x)
- {
- for (m=temp.options.length-1;m>0;m--)
- temp.options[m]=null
- for (i=0;i<group[x].length;i++)
- {
- temp.options[i]=new Option(group[x][i].text,group[x][i].value)
- }
- temp.options[0].selected=true
- }
- function go(){
- location=temp.options[temp.selectedIndex].value
- }
- //-->
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement