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

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

    <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';


    $cnx=mysql_connect('localhost','root','') or die ("Erreur de connexion");


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

    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);


<td >
<select name="isp" value="isp" onChange="changerub(form_1.isp.selectedIndex);">
    <option value="0" selected="selected" >ALL</option>
    $isp_name=mysql_query("SELECT DISTINCT nom_fsi FROM fsi order by nom_fsi asc");
        echo "<option>".$data["nom_fsi"]."</option>";
    <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')">

Recommended Answers

All 3 Replies

Member Avatar

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.

i want to get checkbox from depending on dropdown choice

Member Avatar

That's just repeating your original request.

Because your code is jumbled up all over the place, contributors will need to sift through it and try to make some sense of it. That's not really fair. If you explain in detail what a select field is passing, how it is then supposed to retrieve data (from a DB?) and then what's supposed to happen.

You may find this post helpful:


Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.