Abhay_R Posted June 10, 2019 Share Posted June 10, 2019 (edited) Can anyone help me if retrieve value from database and store into input type="checkbox" in while loop . so 20 checkbox create with value so when in UI if we select one check box then rest of all value will be disable ? any one can help me in this ... 1.First my code where i store sql data 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 id=\"tblFruits\"><label class=\"checkbox-inline\"><input type=\"checkbox\" class=\"Checkboxes4\" name=\"taskprimary[]\ id=\"taskprimary\" value=\"{$row['email']}\" >"; echo"<span>".$row['name']."</span>"."</label></div>"; } echo "</div>"; 2.i am calling that id through ajax 3. in ajax my html page div id i mentation <div class="col-sm-4"> <div class="form-group ui-widget" id="primarydiv"> </div> </div> Edited June 10, 2019 by Abhay_R Link to comment Share on other sites More sharing options...
HartleySan Posted June 10, 2019 Share Posted June 10, 2019 Abhay, I may be misunderstanding the question, but would using radio buttons instead of checkboxes solve your problem? Link to comment Share on other sites More sharing options...
Abhay_R Posted June 10, 2019 Author Share Posted June 10, 2019 Thanku HartleySan . If You don't mine I am asking another question related same field Question: if I have three div where i am print same value from database in three div in radio button format . And database value count is 20 so i am using while loop for like below 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=\"taskprimary\" value=\"{$row['email']}\" >"; echo"<span>".$row['name']."</span>"."</div>"; } and print that value in one div in html page <div class="col-sm-4"> <div class="form-group ui-widget" id="primarydiv"> </div> </div> Now I am trying if anyone select one radio button of first div then that same value of radio button is disable in other two div also . HartleySan or anyone can help me in this Link to comment Share on other sites More sharing options...
Larry Posted June 12, 2019 Share Posted June 12, 2019 I don't quite follow why you would print the same database value in three different radio buttons. Radio buttons are normally used to select one item from a group of items with different values. I also wouldn't use array syntax for the radio button name. You'd only want to do that for something like SELECT menus or checkboxes where multiple values can be selected or checked. Link to comment Share on other sites More sharing options...
Abhay_R Posted June 13, 2019 Author Share Posted June 13, 2019 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 More sharing options...
Recommended Posts