|
-
JavaScript: Checkboxes. Help!
hi guys,
help me with this one..
I have a php code to loop a checkbox; 3 checkboxes.
<?php
for($id=1;$id<=3;$id++){
echo "<input type='checkbox' value='$id' id='check_$id' name='checkboxes'/>";
}
?>
Result:
<input type='checkbox' value='1' id='check_1' name='checkboxes'/>
<input type='checkbox' value='2' id='check_2' name='checkboxes'/>
<input type='checkbox' value='3' id='check_3' name='checkboxes'/>
now, i want to create a javascript or jquery codes to get whether the checkboxes are checked using onlick function.
maybe something like this.
<a href="#" onclick="actionDelete()" />
function actionDelete(){
if(document.getElementsByName("checkboxes").checked == true){
document.mainform.action = "include/db/delete/deleteSelected.php";
document.mainform.submit();
}else{
alert("Please check some checkboxes for deleting");
}
}
my form name is mainform.. if i use getElementById(), then i shud also create a for loop. but i dont want to create a for loop.
i know its easy.. so help me... Beginner!
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
|
Bookmarks