0

Hello,

I want to get checkbox depending on choice dropdown list.
this is my code

<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css"  media="all" charset="utf-8"/>
    <title>APPLICATION</title>


    <script type="text/javascript">
  function changerub(rubrique){
    var divIds= new array('agent');
    for(var i=0; i<divIds.length;i++){
      document.getElementById(divIds[i]).style.display = (i==rubrique)?'block':'none';
    }
  }
</script>
</head>

<body>

<?php
    $cnx=mysql_connect('localhost','root','') or die ("Erreur de connexion");
    mysql_select_db('saher',$cnx);

?>

<form method="post" action="" id="form_1" >
<table border=0 align=center width="100%" cellpadding='3' cellspacing='2'>
<tr>
<th colspan=4>FILTER</th>
</tr>
<tr>
<th>Sensor</th>
<td>
    <div id="agent" style="display:none">
        <?php
            $sig_name=mysql_query("SELECT DISTINCT abreviation,adresse FROM agent");
            $rows=mysql_num_rows($sig_name);
            $cols=mysql_num_fields($sig_name);

    for ($i=0;$i<$rows;$i++)
    {   
            echo '<input name="checkbox[]" type="checkbox" id="checkbox[]" value="'.mysql_result($sig_name,$i,0).'">';
            echo mysql_result($sig_name,$i,0);
    }


    ?>
</div>
</td>

<th>ISP</th>
<td >
<select name="isp" value="isp" onChange="changerub(form_1.isp.selectedIndex);">
    <option value="0" selected="selected" >ALL</option>
    <?php
    $isp_name=mysql_query("SELECT DISTINCT nom_fsi FROM fsi order by nom_fsi asc");
    while($data=mysql_fetch_array($isp_name))
    {
        echo "<option>".$data["nom_fsi"]."</option>";
    }
    ?>
</select>
</td>
</tr>
<tr>
    <td colspan=4>
        <input type="submit" value="Valider" name="filter"  />   
        <input type="submit" value="Generate report" name="report" onClick="openReport('form_1','tcpdf/report2.php')">
    </td>    
</tr>
</table>
</form>
<center>
</body>
</html>
2
Contributors
3
Replies
20
Views
3 Years
Discussion Span
Last Post by diafol
0

Please explain in detail what you wish to achieve. You have javascript, php. sql queries and html all jumbled up. Very difficult to follow.

Separating your php from markup and placing js into listeners is good for producing clean code.

0

i want to get checkbox from depending on dropdown choice

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.