submit 후 체크박스 체크하기
페이지 정보
본문
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;";
}
}
?>
//-->
- 이전글레이어관련.. 마우스 올라갔을적에 특정레이어 불러오기 21.02.10
- 다음글input 또는 textarea 에서 글자수 제한하여 받기 21.02.10
댓글목록
등록된 댓글이 없습니다.