Jump to content
Larry Ullman's Book Forums

Unable to disable radio button which is already selected in another div


Recommended Posts

Unable to disable radio button which is already selected in another  div.

Through ajax we cal database information in  PHP UI page 
1. PHP Ui page where we can print data from database using ajax
<div class="col-sm-4">
                <div class="form-group ui-widget" id="primarydiv">
                </div>
            </div>

<div class="col-sm-4">
                <div class="form-group ui-widget" id="seconddiv">
                </div>
            </div>

<div class="col-sm-4">
                <div class="form-group ui-widget" id="thirddiv">
                </div>
            </div>
2. we create sql.php page where we just write sql query 
while ($row = $resultset->fetch_array(MYSQLI_ASSOC)) {
                     //echo "<option value=\"{$row['email']}\">{$row['name']}</option>";
                     echo "<div><input type=\"radio\" class=\"Checkboxes4\" name=\"taskprimary[]\ id=\"empname\" value=\"{$row['email']}\" >";
                     echo"<span>".$row['name']."</span>"."</div>";    
                }


#imp is Now same database value we print into differentt differnt three div . So in PHP UI page three div create who carry same data. Now problem is when user if select any radio button then same  value will be disable into other two div also 

Edited by Abhay_R
Link to comment
Share on other sites

First, to be clear, the behavior has nothing to do with DIVs (or PHP for that matter). It's simply how radio buttons work in HTML. I'm not quite following what you're trying to do, though. Maybe you should be using checkboxes instead? If you could explain the scenario in more detail I can give more specific advice. 

Link to comment
Share on other sites

Hi Larry I am create first  php page for UI . Second page create where I write SQL Query and Through Ajax call Second page in first page . Now i am doing one project where in UI have Three div and each div have 20 checkbox which is coming by Second Page where we call data through sql query in loop so 20 time data retreive and print in all Three div . Now main thing is all three div have 20 check box  for same employee name . Now condition is if first div user select any employee name checkbox then same name of checkbox disable in other two div check box . so same name not repeat this is aim . I am trying to put different  id for all three <input id=" ">  but its not work . In Sr.no 3 where is use input = " checkbox" rest becaause we need multiple employee selection in one div anther two div show input="radio" because we want to select only one name .Now i want in one div where input ="checkbox" where i select 2 employee name then same name disable another two div but one input is check box and another two div input ="radio" and each div have different id so how can do with radio and  checkbox .  for  why i So could you help me is their possible to put Input id Diiffernt or same .Below my code 

1. UI Page where we print All three Sepreate div with 20 checkbox.

    <div class="col-sm-4">
                <div class="form-group ui-widget" id="reviewerdiv"> ////<- this id retrieve data from Second page while using Ajax
                </div>
    </div>   

   <div class="col-sm-4">
                <div class="form-group ui-widget" id="primarydiv">////<- this id retrieve data from Second page while using Ajax
                </div>
   </div>
            
  <div class="col-sm-4">
                <div class="form-group ui-widget" id="secondarydiv">////<- this id retrieve data from Second page while using Ajax
                </div>
  </div>

 2. Ajax code:

function getSecondary() {
        var ajaxRequest;  // The variable that makes Ajax possible!           
        try {
            // Opera 8.0+, Firefox, Safari
            ajaxRequest = new XMLHttpRequest();                    
        }catch (e) {
            // Internet Explorer Browsers
            try {
                ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
            }catch (e) {
                try {
                    ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
                }catch (e) {
                    // Something went wrong
                    alert("Your browser broke!");
                    return false;
                }
            }
        }
        // Create a function that will receive data
        // sent from the server and will update
        // div section in the same page.        
        ajaxRequest.onreadystatechange = function() {
            if(ajaxRequest.readyState == 4) {
                var ajaxDisplay = document.getElementById('secondarydiv');
                ajaxDisplay.innerHTML = ajaxRequest.responseText;
                RequiredSecondry();
                
            }
        }   
        // Now get the value from user and pass it to
        // server script.
        ajaxRequest.open("GET", "PopulateEmployee.php?name=<?php echo $name; ?>&secondaryname=true", true);
        ajaxRequest.send(null);
    }
    ////////for Primary
    
    function getPrimary() {
        var ajaxRequest;  // The variable that makes Ajax possible!           
        try {
            // Opera 8.0+, Firefox, Safari
            ajaxRequest = new XMLHttpRequest();                    
        }catch (e) {
            // Internet Explorer Browsers
            try {
                ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
            }catch (e) {
                try {
                    ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
                }catch (e) {
                    // Something went wrong
                    alert("Your browser broke!");
                    return false;
                }
            }
        }
        // Create a function that will receive data
        // sent from the server and will update
        // div section in the same page.        
        ajaxRequest.onreadystatechange = function() {
            if(ajaxRequest.readyState == 4) {
                var ajaxDisplay = document.getElementById('primarydiv');
                ajaxDisplay.innerHTML = ajaxRequest.responseText;
                RequiredPrimary();
                
            }
        }   
        // Now get the value from user and pass it to
        // server script.
        ajaxRequest.open("GET", "PopulateEmployee.php?name=<?php echo $name; ?>&primaryname=true", true);
        ajaxRequest.send(null);
    }
    
    
    /////// for reviewer
    
    function getReviewer() {
        var ajaxRequest;  // The variable that makes Ajax possible!           
        try {
            // Opera 8.0+, Firefox, Safari
            ajaxRequest = new XMLHttpRequest();                    
        }catch (e) {
            // Internet Explorer Browsers
            try {
                ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
            }catch (e) {
                try {
                    ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
                }catch (e) {
                    // Something went wrong
                    alert("Your browser broke!");
                    return false;
                }
            }
        }
        // Create a function that will receive data
        // sent from the server and will update
        // div section in the same page.        
        ajaxRequest.onreadystatechange = function() {
            if(ajaxRequest.readyState == 4) {
                var ajaxDisplay = document.getElementById('reviewerdiv');
                ajaxDisplay.innerHTML = ajaxRequest.responseText;
                RequiredReviewer();
                
            }
        }   
        // Now get the value from user and pass it to
        // server script.
        ajaxRequest.open("GET", "PopulateEmployee.php?name=<?php echo $name; ?>&reviewername=true", true);
        ajaxRequest.send(null);
    }
    

3. Second page where i write sql query with inside print of retrieve

 

<?php

$sql = "SELECT * FROM employee WHERE email NOT IN (SELECT boss.email FROM boss) AND email NOT IN (SELECT deactivatedemployee.employee FROM deactivatedemployee)";
    $resultset = $connection->query($sql);
    if(!$resultset) {
        die('Could not get data: ' . $connection->error);
    } else {
            if(isset($_GET['secondaryname'])) {
                echo "<label class=\"label6\" for=\"tasksecondary\">Secondary Responsible:</label>";
                //echo "<select class=\"form-control form-theme\" multiple=\"multiple\" name=\"tasksecondary[]\ id=\"tasksecondary\" required>";
                echo "<div class=\"form-theme form-scroll\" id=\"secondryPerson\" style=\"height: 88px;width: 100%;overflow: auto;padding: 0px 20px;\">";
                echo "<input id=\"searchsecond\" class=\"searchtheme\"; type=\"text\" placeholder=\"Search...\" autocomplete=\"off\">";
                while ($row = $resultset->fetch_array(MYSQLI_ASSOC)) {
                     //echo "<option value=\"{$row['email']}\">{$row['name']}</option>";
                     echo "<div><input type=\"checkbox\" name=\"tasksecondary[]\ id=\"tasksecondary\" value=\"{$row['email']}\" >";
                     echo "<span>".$row['name']."</span>"."</div>";    
                }
                echo "</div>";
            } else if(isset($_GET['primaryname'])){
            
                echo "<label class=\"label6\" for=\"taskprimary\">Primary Responsible:</label>";
                //echo "<select class=\"form-control form-theme\" multiple=\"multiple\" name=\"tasksecondary[]\ id=\"tasksecondary\" required>";
                echo "<div class=\"form-theme form-scroll\" id=\"primaryPerson\" style=\"height: 88px;width: 100%;overflow: auto;padding: 0px 20px;\">";
                echo "<input id=\"searchprimary\" class=\"searchtheme\"; type=\"text\" placeholder=\"Search...\" autocomplete=\"off\">";
                while ($row = $resultset->fetch_array(MYSQLI_ASSOC)) {
                     //echo "<option value=\"{$row['email']}\">{$row['name']}</option>";
                     //echo "<div  ><input type=\"radio\" name=\"taskprimary[]\ id=\"taskprimary\" value=\"{$row['email']}\" >";
                     echo "<div  ><input type=\"radio\" name=\"taskprimary[]\ id=\"taskprimary\" value=\"{$row['email']}\" >";
                     echo"<span>".$row['name']."</span>"."</div>";    
                }
                echo "</div>";
                
            }else if(isset($_GET['reviewername'])){
            
                echo "<label class=\"label6\" for=\"taskreviewer\">Reviewer Responsible:</label>";
                //echo "<select class=\"form-control form-theme\" multiple=\"multiple\" name=\"tasksecondary[]\ id=\"tasksecondary\" required>";
                echo "<div class=\"form-theme form-scroll\" id=\"reviewerPerson\" style=\"height: 88px;width: 100%;overflow: auto;padding: 0px 20px;\">";
                echo "<input id=\"searchreviewer\" class=\"searchtheme\"; type=\"text\" placeholder=\"Search...\" autocomplete=\"off\" >";
                while ($row = $resultset->fetch_array(MYSQLI_ASSOC)) {
                     //echo "<option value=\"{$row['email']}\">{$row['name']}</option>";
                     //echo "<div><input type=\"radio\" name=\"taskreviewer[]\ id=\"taskreviewer\" value=\"{$row['email']}\" >";
                     echo "<div><input type=\"radio\" name=\"taskreviewer[]\ id=\"taskreviewer\" value=\"{$row['email']}\" >";
                     echo"<span>".$row['name']."</span>"."</div>";  
                }
                echo "</div>";
            
           
            }

     }

?>

Link to comment
Share on other sites

Hi Larry we do same thing with check box also so can you help me how can do that with three div where all input="checkbox". as per your suggestion i am not using radio i am using checkbox but how can design code where one or multiple employee name select in one div that will disable in other two div also

Link to comment
Share on other sites

 Share

×
×
  • Create New...