Hi,
On my email program, I have list of headers of new Emails. when I click 'Delete' , programm has to POST the values of checked checkboxes to delete them after confirmation.
Please tell me is there any way to detect the values of checkboxes and post them to another page.
I feel it should be a function that I can call 'on click' the button 'Delete'
[56K WARN] Post Check box value
Moderator: General Moderators
checkboxes "ship" like any other input control, as name=value pair.
If they are checked when the form is submitted their name and current value are sent to the server where php can process them.
If they are checked when the form is submitted their name and current value are sent to the server where php can process them.
Code: Select all
<html>
<head>
<title>checkbox test</title>
</head>
<body>
<?php
if ( isset($_POST['xyz']) && is_array($_POST['xyz']) ) {
foreach( $_POST['xyz'] as $xyz ) {
echo ' checkbox value: ', (int)$xyz, "<br />\n";
}
}
?>
<form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<div>
1 <input type="checkbox" name="xyz[]" value="1" /><br />
2 <input type="checkbox" name="xyz[]" value="2" /><br />
3 <input type="checkbox" name="xyz[]" value="3" /><br />
4 <input type="checkbox" name="xyz[]" value="4" /><br />
5 <input type="checkbox" name="xyz[]" value="5" /><br />
<input type="submit" />
</div>
</form>
</body>
</html>feyd | Please use
With this code, I can have a massage with Cbox value or name. But I need to Post them. If you can edit above function for my purpose, Its also OK.
Thanks.
feyd | Please use[/syntax]
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Thanks for the post.
But in my case 'Checkboxes' are extremely seperate from the 'DELETE BUTTON'.
I'm unable to put all Checkboxes and Submit Button together in a form tag as you've done.
Some thing like this.
[syntax="html"]<script language="javascript">
function sec() {
var myFormsLen = document.formName.elements.length;
for(i=0; i<myFormsLen; i++) {
if(document.formName.elements[i].type == 'checkbox' &&
document.formName.elements[i].checked) {
alert(document.formName.elements[i].nextSibling.data);
}
}
}
</script>
<button onclick="sec();">button</button>
<form name="formName">
<label><input type="checkbox">1111</label><br>
<label><input type="checkbox">2222</label><br>
<label><input type="checkbox">3333</label><br>
<label><input type="checkbox">4444</label><br>
<label><input type="checkbox">5555</label><br>
</form> Thanks.
feyd | Please use[/syntax]
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]