Search the Community
Showing results for tags 'checkbox'.
-
I am creating a Child Security Application called Shield Child Security. I ran into a roadblock, and I had to ask myself, "How will they take attendance?" So I want to take a mass status change. If you look at the picture you will see what I mean. <body> <div align="center"> <div style="width:460px; background-color:#000000; padding:11px;" align="left" class="shadow"> Children: <div style="background-color:#3399FF; padding:11px;" align="left" class="shadow"> <form action="" method="POST"> <table> <?php $query = mysql_query("SELECT * FROM Children WHERE classroom='$class'") or die("ERROR"); $numrows = mysql_num_rows($query); if ($numrows!=0){ while ($row = mysql_fetch_assoc($query)){ $cid = $row['id']; $fname = $row['firstname']; $lname= $row['lastname']; $status = $row['status']; $classroom = $row['classroom']; echo '<tr style="background-color:gray;"><td><input type="checkbox"></td><td align="center" width="150" name="'.$cid.'">[<a href="child.php?id='.$cid.'">'.$fname.' '.$lname.'</a>]</td>'; if ($classroom != 'none'){ if ($status == 1) { echo '<td align="center" width="200"><font color="red">Not Present</font>'; } else if ($status == 2){ echo '<td align="center" width="200"><font color="lightgreen">Present</font>';} } else { echo '<td align="center" vertical-align="middle"><br><form action="changeclass.php" method="POST"><select>Balls</select><input type="submit" value="+""></form></td>'; } echo '</td><td align="center"><a href="delete.php?id='.$cid.'&type=child">[ - ]</a></td></tr>'; } } else {echo "No Students";} ?> <tr> </tr> </table> <table> <td> <input type = "submit" value="Switch Status"> </td> </table </div> <br> <a href="classroom.php">Go Back</a> </div> </div> I'm sure its vulnerable to SQL Injection, but remember this is just a rough draft. A draft to get my ideas out in code. Peace! And Thank You!
-
HI, I am a newbie using Dreamweaver to create a form that has a checbox next to students's names. Once you select the student's you wish to see, you hit submit and it sends you to anther page where it displays the profiles for each of these students so they can be printed. My form looks like this: <form id="form1" name="form1" method="post" action="test4.php"> <?php do { ?> <p> <input name="UID[]" type="checkbox" id="UID" value="<?php echo $row_applicants['UID']; ?>" /> <label for="UID"></label> <?php echo $row_applicants['FNAME']; ?> <?php echo $row_applicants['LNAME']; ?> </p> <?php } while ($row_applicants = mysql_fetch_assoc($applicants)); ?> <p> <input type="submit" name="button" id="button" value="Submit" /> </p> </form> My test results page looks like this: mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error()); mysql_select_db($dbname) or die(mysql_error()); $UID = $_POST['UID']; $query = "SELECT * FROM users WHERE UID = ('$UID')"; $results = mysql_query($query) or die(mysql_error()); if(mysql_num_rows($results)==1){ // If there is only one row that was returned $results = mysql_fetch_array($results); echo $results['UID']; // If the column name is incorrect, just change it to match }elseif(mysql_num_rows($results)>1){ // If there is more than one row that was returned while($result=mysql_fetch_array($results)){ // Loop through each row that was returned and display it echo $result['UID']." "; } }else{ //If there were no rows returned, this is just to account for every option and is entirely optional echo "No matched!"; } I want the end result page to look like the attached file with multiple profiles. Thanks in advance
-
Hi! Any suggestions of how to set the // Set email variables & // simple email content for a checkbox to attach a copy of the message to the actual sender? In which case, I obviously do not know in advance to which email address this Cc attachment should be send... Anyone who can help me further? Thx
- 2 replies
-
- cc
- attachment
-
(and 2 more)
Tagged with:
-
I am having an issue getting the values checked in the check-box. I have tried to clean up the code. I can get the all the selected check-boxes selected (but not per row) or i can get the check-box id per row but not the selected value. I am pretty sure I can transfer the values to the another page but do not know how to get them. Any assistance here would greatly be appreciated! //php variables used $pages = 2 $size = 4 < form id="form" name="cb"> < div style=" width:800px; height:500px; overflow:auto"> < h2>Select Editions</h2> < table id='table' name='table' border=1 cellpadding=7 width=50% height=50% align='center'>\n for($x = 1; $x <= $pages; $x++) : print "<td id='page_$x' class='page_button' align='center' custom='0' >Page $x - "; for($i = 1; $i <= $size; $i++) : print "<input type='checkbox' class='ebutton' id='etype_$x' name='checks[]' value='$i' /> $i"; endfor; </td> </tr> endfor; with this as the Javascript $(document).ready(function() { $(".ebutton").change(function() { var idp = $(this).attr("id").split("_"); var page_num = idp[1]; // I need to find out how to get the checkboxes that are checked per row. Ex: 01,02 //var editions = ?; //alert(editions); var hidden_id = "#etype_page_" + page_num; if($(hidden_id).length < 1) { $("#base").append('<input type="hidden" id="etype_page_'+ page_num +'" name="'+ page_num +'" value="'+ editions +'" class="hidden_edtype" custom="' + editions +'">'); } else { $(hidden_id).val($(this).val()); } update_eShow(); }); }); function update_eShow() { $("#eShow").html(''); $(".hidden_edtype").each(function() { var page = $(this).attr("name"); var value = $(this).attr("custom"); $("#eShow").append('page:' + page + ' values:' + value +'<br>'); }); } page looks like this: | Page 1 - []1 []2 []3 []4 | | Page 2 - []1 []2 []3 []4 | Here is what I have been able to get, but its not right: I select both 01 and 02 for page 1 and only 01 for page 2. My results are: Page:1 Values: 01 Page:2 Values: 01,02,01
- 7 replies
-
- checkboxlist
- javascript
-
(and 3 more)
Tagged with:
-
Hi! I'm working on a projekt that I need help with. I'm completely stuck. The code will 1. Get rows from a mysql-table. 2. Print a checkbox for each row. 3. In the table there's a column named "enabled" which is either 0 or 1. If enabled=1 the checkbox for that row will be checked and vice versa. 4. You should be able to check AND uncheck boxes however you want, hit submit and all rows will get updated with either enabled=0 or enabled=1. The first 3 works, but I'm still missing number 4. No idea on how to do this. Can anyone explain how I can write the missing code? <?php # db-information to variables $host = "localhost"; $username = "root"; $userpass = "mypassword"; $dbname = "drift"; # Connect to db $dbconnect = mysql_connect($host,$username,$userpass); if (!$dbconnect) { die("Could not connect to database. " . mysql_error()); } # Choose db $dbselect = mysql_select_db($dbname,$dbconnect); if (!$dbselect) { die("Could not select database. " . mysql_error()); } ########### Get the rows and print them like checkboxes echo "Välj platser:<br />"; echo "<form action=\"test.php\" method=\"post\">"; $query = mysql_query("SELECT * FROM drifttable"); while($result = mysql_fetch_assoc($query)) { if ($result[enabled] == 1) { echo "<input type=\"checkbox\" name=\"places[]\" value=\"$result[id]\" checked=\"checked\">$result[descr]<br />"; } elseif ($result[enabled] == 0) { echo "<input type=\"checkbox\" name=\"places[]\" value=\"$result[id]\">$result[descr]<br />"; } else { exit ("Couldn't get 0 or 1 from 'enabled' in db"); } } echo "<input type=\"submit\" />"; echo "</form><br />"; ########### Update the db with new values ########### Closes the MySQL connection mysql_close(dbconnect); ?>
-
Hello, I have a table that I read in from a postgresql database but I need to add a column that has checkboxes in the final row. It is for a shop so then when the item is selected via checkbox I can then press an add to cart button and send this using an array to the cart.php page. Firstly I need to be able to add checkboxes to the end of each row before I can even do that and I am struggling at how to get a checkbox at the end of each row of my table. <form action="index.php" method="post"> <table> <tr> <th>ref</th> <th>title</th> <th>platform</th> <th>description</th> <th>price</th> <th>select</th> </tr> <?php $resource = pg_query ($connect, "select refnumber,title,platform,description,price from CSGames"); while ($row = pg_fetch_array ($resource)) { $result[] = $row; } foreach($result as $key => $value) { echo "<tr>"; for ($j = 0; $j < pg_num_fields ($resource); $j++) { echo "<td>".$a[$j]."</td>"; } echo "</tr>"; } ?> </table> Could any help with this and explain so I can understand what is occurring in the future please?
-
I have a table contained by a form. Each row of the table contains the following data cells: <td> <input type='text' name='cart[ccr-01-002]' size='2' /> </td> <td> <input type='checkbox' name='delete[ccr-01-002]' /> </td> Rather than returning whether or not the checkbox is checked (such as ON or OFF), it is instead returning the value of the text input field. Here is how I am trying to reference it: var_dump($_POST['delete']); This prints out the string contents of the text fields instead of ON or OFF. Is it possible (without having to put the checkbox into its own form) to reference the checkbox as a separate entity from the text input? I would like to reference $_POST['cart'], and not have it affect $_POST['delete']. Please let me know if you need any other information!
-
Hi Guys, I have a set of script to send data via checkbox toggle. After a checkbox is checked. A value is sent from PHP as 1. So I test the value within success callback. Everythings works fine but I can't make the background color change according to the given value from php. Please have give me a hand. <script type="text/javascript"> jQuery(function($){ $('input[name=alm]').click(function(){ var id=$(this).attr('id'); var alm=$(this).val(); $.ajax({ type:'GET', url:'inc/villas_allotment_ajax_update.php', data:'id='+id+'&alm='+alm, /*success: function (result) {$('#bg').css("background-color", "#66cc00");alert(data);}, error: function (result) {$('#bg').css("background-color", "#ff8080");},*/ success: function(html) { if(html=="1"){//change td bg to green if succeed $('#bg').css("background-color", "#66cc00"); alert(html); }else{ $('#bg').css("background-color", "#ff8080"); alert(html); } } }); }); }); </script> Here's my html: <table> [indent=1]<tr>[/indent] [indent=2]<td id="2012-11-01-001" align="center"><input type="checkbox" id="2012-11-01-001" name="alm" value="1" checked /></td>[/indent] [indent=2]<td id="2012-11-02-001" align="center"><input type="checkbox" id="2012-11-02-001" name="alm" value="1" checked /></td>[/indent] [indent=2]<td id="2012-11-03-001" align="center"><input type="checkbox" id="2012-11-03-001" name="alm" value="1" checked /></td>[/indent] [indent=2]...[/indent] [indent=2]<td id="2012-11-30-001" align="center"><input type="checkbox" id="2012-11-30-001" name="alm" value="1" checked /></td>[/indent] [indent=1]</tr>[/indent] </table> The questions is: How can I change the td background-color after a callback is proved (html=="1") according to its td.id (not #bg as I wrote) Please help me out, I've spent many hours to solve this including some samples from this website.
-
How could I declare checkbox, if checkbox is checked = 1 else = 0.And insert to mySQL. <input type="checkbox" name="homepage" value="1" /> <-----this is my checkbox code. Only this i know. somemore,if i already insert data to mySQL, how could i display checkbox is checked based on database, 1 = checked, 0 = unchecked. I had try many code,but it won't work as well..Now i've no idea. P/S:I'm using php code. Please help. Thanks. Regards.