submit 후 체크박스 체크하기
페이지 정보
작성자 최고관리자 작성일 21-02-10 17:30 조회 7,454 댓글 0본문
function formcheck ()
{
var checkedCount;
var checkboxes = document.getElementsByName("check_name[]");
checkedCount = 0 ;
for(var i=0; i < checkboxes.length; i++) {
if(checkboxes[i].checked) checkedCount++ ;
}
if(checkedCount <= 0)
{
alert ("체크박스를 체크 선택하세요.!");
return false;
}
}
-----------------------------------------------------
<?
$sSQL = "Select ";
$resultS = mysql_query($sSQL);
$tcnt = mysql_num_rows($resultS);
$icnt = 0;
?>
<script>
function Valcheck(){
var guval = "";
var ckLength = <?=$tcnt?>;
for (var i=1; i<=ckLength; i++){
if (eval("guCk.area2CK" + i + ".checked") == true){
if (guval == ""){
guval = eval("guCk.area2CK" + i + ".value");
} else {
guval += "!" + eval("guCk.area2CK" + i + ".value");
}
}
}
parent.sfrm.guval.value=guval;
}
</script>
<form name=guCk >
<?
$icnt = 0;
for ($j=1; $j<=3; $j++){
$rowS = mysql_fetch_row($resultS);
if ($rowS){
$icnt++;
echo "<input type='checkbox' name='area2CK{$icnt}' value='{$rowS[0]}' OnClick=\"Valcheck(this.form);\"> {$rowS[0]}";
}
}
}
?>
<input type=hidden name=Gucnt value="<?=$icnt?>">
</form>
</table>
</body>
<script>
<?
$tmp_guval = explode ("!", $guval);
for ($j=0; $j < sizeof($tmp_guval); $j++){
eval("\$tmpArea = \$tmp_guval[{$j}];");
if($tmpArea){
for($i=1; $i <= $tcnt; $i++){
echo "
if(guCk.area2CK{$i}.value == \"$tmpArea\"){
guCk.area2CK{$i}.checked = true;
}
";
}
}
}
?>
</script>
#######################################################################
<?
$sSQL = "Select";
$resultS = mysql_query($sSQL);
$tcnt = mysql_num_rows($resultS);
//체크박스부분
for ($i=1; $i<=$tcnt; $i++){
echo "<input type='checkbox' name='area2CK{$i}' value='{$rowS[0]}'>{$rowS[1]}";
}
//받아온 값 체크 부분
for ($i=1; $i<=$tcnt; $i++){
eval("\$tmpArea = \$area2CK{$i};");
if ($tmpArea){
echo "{$form_name}.area2CK{$i}.checked = true;";
}
}
?>
//-->
{
var checkedCount;
var checkboxes = document.getElementsByName("check_name[]");
checkedCount = 0 ;
for(var i=0; i < checkboxes.length; i++) {
if(checkboxes[i].checked) checkedCount++ ;
}
if(checkedCount <= 0)
{
alert ("체크박스를 체크 선택하세요.!");
return false;
}
}
-----------------------------------------------------
<?
$sSQL = "Select ";
$resultS = mysql_query($sSQL);
$tcnt = mysql_num_rows($resultS);
$icnt = 0;
?>
<script>
function Valcheck(){
var guval = "";
var ckLength = <?=$tcnt?>;
for (var i=1; i<=ckLength; i++){
if (eval("guCk.area2CK" + i + ".checked") == true){
if (guval == ""){
guval = eval("guCk.area2CK" + i + ".value");
} else {
guval += "!" + eval("guCk.area2CK" + i + ".value");
}
}
}
parent.sfrm.guval.value=guval;
}
</script>
<form name=guCk >
<?
$icnt = 0;
for ($j=1; $j<=3; $j++){
$rowS = mysql_fetch_row($resultS);
if ($rowS){
$icnt++;
echo "<input type='checkbox' name='area2CK{$icnt}' value='{$rowS[0]}' OnClick=\"Valcheck(this.form);\"> {$rowS[0]}";
}
}
}
?>
<input type=hidden name=Gucnt value="<?=$icnt?>">
</form>
</table>
</body>
<script>
<?
$tmp_guval = explode ("!", $guval);
for ($j=0; $j < sizeof($tmp_guval); $j++){
eval("\$tmpArea = \$tmp_guval[{$j}];");
if($tmpArea){
for($i=1; $i <= $tcnt; $i++){
echo "
if(guCk.area2CK{$i}.value == \"$tmpArea\"){
guCk.area2CK{$i}.checked = true;
}
";
}
}
}
?>
</script>
#######################################################################
<?
$sSQL = "Select";
$resultS = mysql_query($sSQL);
$tcnt = mysql_num_rows($resultS);
//체크박스부분
for ($i=1; $i<=$tcnt; $i++){
echo "<input type='checkbox' name='area2CK{$i}' value='{$rowS[0]}'>{$rowS[1]}";
}
//받아온 값 체크 부분
for ($i=1; $i<=$tcnt; $i++){
eval("\$tmpArea = \$area2CK{$i};");
if ($tmpArea){
echo "{$form_name}.area2CK{$i}.checked = true;";
}
}
?>
//-->
댓글목록 0
등록된 댓글이 없습니다.