kvnirvana Posted August 17, 2010 Share Posted August 17, 2010 Anyone knows why the fourth drop down wont populate? The first, second and third drop works perfect, but I just can’t get the fourth to work. Please help me I’m totally lost <script language="javascript"> function reload(form){ var val=form.behan.options[form.behan.options.selectedIndex].value; var val2=form.omraede.options[form.omraede.options.selectedIndex].value; var val3=form.navn.options[form.navn.options.selectedIndex].value; self.location='perfekt.php?behan=' + val +'&omraede=' + val2 +'&navn=' + val3 ; } </script> <div class="content_top"></div> <div class="content_only"> <?php $dbservertype='mysql'; // hostname or ip of server $servername='localhost'; $dbusername='****'; $dbpassword='****'; $dbname='****'; //////////////////////////////////////// ////// DONOT EDIT BELOW ///////// /////////////////////////////////////// connecttodb($servername,$dbname,$dbusername,$dbpassword); function connecttodb($servername,$dbname,$dbuser,$dbpassword) { global $link; $link=mysql_connect ("$servername","$dbuser","$dbpassword"); if(!$link){die("Could not connect to MySQL");} mysql_select_db("$dbname",$link) or die ("could not open db".mysql_error()); } if (isset($_POST['submit'])) ?> <form action="<?php echo $_SERVER['PHP_SELF']?>" method="post"> <table width='100%' align='center' valign='center'> <tr> <td colspan='2' align='center' style='font-family:verdana;font-size:130%;'><strong> </strong><br></br></td> </tr> <th align="left" scope="col"> </table> <?php @$cat=$_GET['behan']; @$catt=$_GET['omraede']; @$cattt=$_GET['navn']; @$catttt=$_GET['id']; /* if(strlen($cat) > 0 and !is_numeric($cat)){ echo "Data Error"; exit; } */ $quer1=mysql_query("SELECT DISTINCT behan FROM be order by id"); if(isset($cat) and strlen($cat) > 0){ $quer2=mysql_query("SELECT distinct omraede FROM be WHERE behan='$cat' order by id"); } if(isset($catt) and strlen($catt) > 0){ $quer3=mysql_query("SELECT distinct navn FROM be WHERE behan='$cat' and omraede='$catt' order by id"); } if(isset($cattt) and strlen($cattt) > 0){ $quer4=mysql_query("SELECT postnr FROM be WHERE behan='$cat' and omraede='$catt' and navn='$cattt' order by id"); } // First drop down echo "<table width='50%' style='position:absolute;left:545px;top:70px;width:100%;height:100%'>"; echo "<tr>"; echo "<td style='font-family:verdana;font-size:110%;'>Vælg område:</td>"; echo "<select name='behan' onchange=\"reload(this.form)\"><option value=''>behan</option>"; while($noticia2 = mysql_fetch_array($quer1)) { if($noticia2['behan']==@$cat){ echo "<option selected value='$noticia2[behan]'>$noticia2[behan]</option>"."<br />"; }else{ echo "<option value='$noticia2[behan]'>$noticia2[behan]</option>"; } } echo "</select>"; echo "<td"; echo "<tr>"; // Second drop down echo "<br>"; echo "<br>"; echo "<tr>"; echo "<td style='font-family:verdana;font-size:110%;'>Vælg område:</td>"; echo "<select name='omraede' onchange=\"reload(this.form)\"><option value=''>Vælg område</option>"; while($noticia = mysql_fetch_array($quer2)) { if($noticia['omraede']==@$catt){ echo "<option value='$noticia[omraede]'>$noticia[omraede]</option>"; }else{ echo "<option value='$noticia[omraede]'>$noticia[omraede]</option>"; } } echo "</select>"; echo "<td"; echo "<tr>"; // Third drop down echo "<br>"; echo "<br>"; echo "<tr>"; echo "<td style='font-family:verdana;font-size:110%;'>Vælg navn:</td>"; echo "<select name='navn' onchange=\"reload(this.form)\"><option value=''>Vælg navn</option>"; while($noticia = mysql_fetch_array($quer3)) { if($noticia['navn']==@$cattt){ echo "<option value='$noticia[navn]'>$noticia[navn]</option>"; }else{ echo "<option value='$noticia[navn]'>$noticia[navn]</option>"; } } echo "</select>"; echo "<td"; echo "<tr>"; echo "<br>"; echo "</table>"; echo "<br>"; echo "<br>"; echo "<br>"; echo "<br>"; echo "<br>"; echo "<br>"; echo "<br>"; echo "<br>"; echo "<table>"; echo "<DIV style='position:absolute;center:0px;top:0px;width:100%;height:100%;z-index:1' align='left'><TABLE width='100%' height='100%' border='0' cellpadding='0' cellspacing='1'><TR><TD align='left' valign='top' width='100%' height='40'><FONT style='font-size:16px' color='#000000' face='Arial'><B><hr></B></FONT></TD></TR></TABLE></DIV>"; echo "</table>"; // Fourth drop down echo "<table width='50%' style='position:absolute;left:545px;top:370px;width:100%;height:100%'>"; echo "<td style='font-family:verdana;font-size:110%;'>bb:</td>"; echo "<tr>"; echo "<select name='postnr'><option value=''>Vælg postnr</option>"; while($noticia = mysql_fetch_array($quer4)) { if($noticia['postnr']==@$cattt){ echo "<option value='$noticia[postnr]'>$noticia[postnr]</option>"; }else{ echo "<option value='$noticia[postnr]'>$noticia[postnr]</option>"; } } echo "</select>"; echo "<td"; echo "<tr>"; echo "<table>"; ?> Link to comment https://forums.phpfreaks.com/topic/210983-4-drop-down-wont-work/ Share on other sites More sharing options...
monkeytooth Posted August 17, 2010 Share Posted August 17, 2010 Ok I am assuming that if($noticia2['behan']==@$cat){ is the part that catches the last entry for the drop down. I am going to guess that the likely reason it may not be showing up is due to the ."<br>" as thats an invalid tag inside of a <select> Link to comment https://forums.phpfreaks.com/topic/210983-4-drop-down-wont-work/#findComment-1100415 Share on other sites More sharing options...
kvnirvana Posted August 17, 2010 Author Share Posted August 17, 2010 Ok, so I made the changes but still it wont work The code now looks like this <script language="javascript"> function reload(form){ var val=form.behan.options[form.behan.options.selectedIndex].value; var val2=form.omraede.options[form.omraede.options.selectedIndex].value; var val3=form.navn.options[form.navn.options.selectedIndex].value; self.location='perfekt.php?behan=' + val +'&omraede=' + val2 +'&navn=' + val3 ; } </script> <div class="content_top"></div> <div class="content_only"> <?php $dbservertype='mysql'; // hostname or ip of server $servername='localhost'; $dbusername='****'; $dbpassword='****'; $dbname='****'; //////////////////////////////////////// ////// DONOT EDIT BELOW ///////// /////////////////////////////////////// connecttodb($servername,$dbname,$dbusername,$dbpassword); function connecttodb($servername,$dbname,$dbuser,$dbpassword) { global $link; $link=mysql_connect ("$servername","$dbuser","$dbpassword"); if(!$link){die("Could not connect to MySQL");} mysql_select_db("$dbname",$link) or die ("could not open db".mysql_error()); } if (isset($_POST['submit'])) ?> <form action="<?php echo $_SERVER['PHP_SELF']?>" method="post"> <table width='100%' align='center' valign='center'> <tr> <td colspan='2' align='center' style='font-family:verdana;font-size:130%;'><strong> </strong><br></br></td> </tr> <th align="left" scope="col"> </table> <?php @$cat=$_GET['behan']; @$catt=$_GET['omraede']; @$cattt=$_GET['navn']; @$catttt=$_GET['id']; /* if(strlen($cat) > 0 and !is_numeric($cat)){ echo "Data Error"; exit; } */ $quer1=mysql_query("SELECT DISTINCT behan FROM be order by id"); if(isset($cat) and strlen($cat) > 0){ $quer2=mysql_query("SELECT distinct omraede FROM be WHERE behan='$cat' order by id"); } if(isset($catt) and strlen($catt) > 0){ $quer3=mysql_query("SELECT distinct navn FROM be WHERE behan='$cat' and omraede='$catt' order by id"); } if(isset($cattt) and strlen($cattt) > 0){ $quer4=mysql_query("SELECT postnr FROM be WHERE behan='$cat' and omraede='$catt' and navn='$cattt' order by id"); } // First drop down echo "<table width='50%' style='position:absolute;left:545px;top:70px;width:100%;height:100%'>"; echo "<tr>"; echo "<td style='font-family:verdana;font-size:110%;'>Vælg område:</td>"; echo "<select name='behan' onchange=\"reload(this.form)\"><option value=''>behan</option>"; while($noticia2 = mysql_fetch_array($quer1)) { if($noticia2['behan']==@$cat){ echo "<option selected value='$noticia2[behan]'>$noticia2[behan]</option>"; }else{ echo "<option value='$noticia2[behan]'>$noticia2[behan]</option>"; } } echo "</select>"; echo "<td"; echo "<tr>"; // Second drop down echo "<br>"; echo "<br>"; echo "<tr>"; echo "<td style='font-family:verdana;font-size:110%;'>Vælg område:</td>"; echo "<select name='omraede' onchange=\"reload(this.form)\"><option value=''>Vælg område</option>"; while($noticia3 = mysql_fetch_array($quer2)) { if($noticia3['omraede']==@$catt){ echo "<option value='$noticia3[omraede]'>$noticia3[omraede]</option>"; }else{ echo "<option value='$noticia3[omraede]'>$noticia3[omraede]</option>"; } } echo "</select>"; echo "<td"; echo "<tr>"; // Third drop down echo "<br>"; echo "<br>"; echo "<tr>"; echo "<td style='font-family:verdana;font-size:110%;'>Vælg navn:</td>"; echo "<select name='navn' onchange=\"reload(this.form)\"><option value=''>Vælg navn</option>"; while($noticia4 = mysql_fetch_array($quer3)) { if($noticia4['navn']==@$cattt){ echo "<option value='$noticia4[navn]'>$noticia4[navn]</option>"; }else{ echo "<option value='$noticia4[navn]'>$noticia4[navn]</option>"; } } echo "</select>"; echo "<td"; echo "<tr>"; echo "<br>"; echo "</table>"; echo "<br>"; echo "<br>"; echo "<br>"; echo "<br>"; echo "<br>"; echo "<br>"; echo "<br>"; echo "<br>"; echo "<table>"; echo "<DIV style='position:absolute;center:0px;top:0px;width:100%;height:100%;z-index:1' align='left'><TABLE width='100%' height='100%' border='0' cellpadding='0' cellspacing='1'><TR><TD align='left' valign='top' width='100%' height='40'><FONT style='font-size:16px' color='#000000' face='Arial'><B><hr></B></FONT></TD></TR></TABLE></DIV>"; echo "</table>"; // Fourth drop down echo "<table width='50%' style='position:absolute;left:545px;top:370px;width:100%;height:100%'>"; echo "<td style='font-family:verdana;font-size:110%;'>bb:</td>"; echo "<tr>"; echo "<select name='postnr'><option value=''>Vælg postnr</option>"; while($noticia5 = mysql_fetch_array($quer4)) { if($noticia5['postnr']==@$cattt){ echo "<option value='$noticia5[postnr]'>$noticia5[postnr]</option>"; }else{ echo "<option value='$noticia5[postnr]'>$noticia5[postnr]</option>"; } } echo "</select>"; echo "<td"; echo "<tr>"; echo "<table>"; ?> Link to comment https://forums.phpfreaks.com/topic/210983-4-drop-down-wont-work/#findComment-1100489 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.