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
https://forums.phpfreaks.com/topic/187239-help-me-may-be-silly-for-you/
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>

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>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.