Jump to content

help me may be silly for you


mubarakabbas

Recommended Posts

Hi,

 

i want the form with check all and Uncheck all, javascript is not working

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Untitled Document</title>

 

 

<SCRIPT LANGUAGE="JavaScript">

<!--

 

<!-- Begin

function CheckAll(check_list)

{

for (i = 0; i < check_list.length; i++)

check_list.checked = true ;

}

 

function UnCheckAll(check_list)

{

for (i = 0; i < check_list.length; i++)

check_list.checked = false ;

}

// End -->

</script>

 

 

 

</head>

 

<body>

 

<?php

if(isset($_POST[chk]))

{

 

for($i=0;$i<5;$i++)

{

echo $_POST['check_list'][$i];

 

}

 

echo "hi";

exit();

 

 

 

 

 

}

?>

 

This is the HTML code to be kept inside the body tag.

<form name="myform" action="check.php" method="post">

<b>Scripts for Web design and programming</b><br>

<input type="checkbox" name="check_list[]" value="1">ASP<br>

<input type="checkbox" name="check_list[]" value="2">PHP<br>

<input type="checkbox" name="check_list[]" value="3">JavaScript<br>

<input type="checkbox" name="check_list[]" value="4">HTML<br>

<input type="checkbox" name="check_list[]" value="5">MySQL<br>

 

<input type="button" name="Check_All" value="Check All"

onClick="CheckAll(document.myform.check_list)">

<input type="button" name="Un_CheckAll" value="Uncheck All"

onClick="UnCheckAll(document.myform.check_list)">

 

<input type="submit" name="chk" value="CHK" />

 

 

</body>

</html>

 

Link to comment
Share on other sites

not perfect but I guess it should give you an idea

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>


<SCRIPT LANGUAGE="JavaScript">
<!--

<!-- Begin
function CheckAll(form, name)
{
for (var i=0;i<form.elements.length;i++) {
    var e = form.elements[i];
    if (e.type=='checkbox' && e.name.indexOf(name) == 0 && !e.disabled) {
      e.checked = true;
    }
    }
}

function UnCheckAll(form, name)
{
for (var i=0;i<form.elements.length;i++) {
    var e = form.elements[i];
    if (e.type=='checkbox' && e.name.indexOf(name) == 0 && !e.disabled) {
      e.checked = false;
    }
    }
}
// End -->
</script>



</head>

<body>

<?php
if(isset($_POST[chk]))
{

for($i=0;$i<5;$i++)
{
echo $_POST['check_list'][$i];

}

echo "hi";
exit();





}
?>

This is the HTML code to be kept inside the body tag.
<form name="myform" action="check.php" method="post">
<b>Scripts for Web design and programming</b><br>
<input type="checkbox" name="check_list[]" value="1">ASP<br>
<input type="checkbox" name="check_list[]" value="2">PHP<br>
<input type="checkbox" name="check_list[]" value="3">JavaScript<br>
<input type="checkbox" name="check_list[]" value="4">HTML<br>
<input type="checkbox" name="check_list[]" value="5">MySQL<br>

<input type="button" name="Check_All" value="Check All"
onClick="CheckAll(this.form, 'check_list')">
<input type="button" name="Un_CheckAll" value="Uncheck All"
onClick="UnCheckAll(this.form, 'check_list')">

<input type="submit" name="chk" value="CHK" />


</body>
</html>

Link to comment
Share on other sites

thank you brother for your hands,

 

but still am not getting javascript write...

 

if i remove the array_name[] parameter its working,

 

 

not perfect but I guess it should give you an idea

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>


<SCRIPT LANGUAGE="JavaScript">
<!--

<!-- Begin
function CheckAll(form, name)
{
for (var i=0;i<form.elements.length;i++) {
    var e = form.elements[i];
    if (e.type=='checkbox' && e.name.indexOf(name) == 0 && !e.disabled) {
      e.checked = true;
    }
    }
}

function UnCheckAll(form, name)
{
for (var i=0;i<form.elements.length;i++) {
    var e = form.elements[i];
    if (e.type=='checkbox' && e.name.indexOf(name) == 0 && !e.disabled) {
      e.checked = false;
    }
    }
}
// End -->
</script>



</head>

<body>

<?php
if(isset($_POST[chk]))
{

for($i=0;$i<5;$i++)
{
echo $_POST['check_list'][$i];

}

echo "hi";
exit();





}
?>

This is the HTML code to be kept inside the body tag.
<form name="myform" action="check.php" method="post">
<b>Scripts for Web design and programming</b><br>
<input type="checkbox" name="check_list[]" value="1">ASP<br>
<input type="checkbox" name="check_list[]" value="2">PHP<br>
<input type="checkbox" name="check_list[]" value="3">JavaScript<br>
<input type="checkbox" name="check_list[]" value="4">HTML<br>
<input type="checkbox" name="check_list[]" value="5">MySQL<br>

<input type="button" name="Check_All" value="Check All"
onClick="CheckAll(this.form, 'check_list')">
<input type="button" name="Un_CheckAll" value="Uncheck All"
onClick="UnCheckAll(this.form, 'check_list')">

<input type="submit" name="chk" value="CHK" />


</body>
</html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.