메뉴 건너뛰기

프로그램언어

조회 수 1807 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄

체크를 한 것들을 선택하고 그 값을 DB에 담긴 것을 꺼내어 선택된 것을 체크되게 해주는 것입니다.

실제 업무에도 많이 쓰이기도 하고 또한 CSS나 웹표준으로도 변환해서 이용하시면 될 듯합니다..


 


function caeSubmit(f) {

        msgChecked(f);

        if (count < 1) {

           alert("선택하신 제품구분이 없습니다.\n제품구분을 선택하여 주시기 바랍니다.");

           f.bunya1[0].focus();

           f.bunya1[0].checked==true;

           return false;

        }




        f.target="deffrm";

        f.method="post";

        f.action="act.php?mode=caeSave";

        f.submit();

}




function msgChecked(f) {

     var i=0;

 count = 0;

 CheckedItems1="";

 while (i < f.elements.length) {

      if ((f.elements[i].name == 'bunya1') && (f.elements[i].checked)) {

                        CheckedItems1 += f.elements[i].value + "*";

                        f.chkitem1.value=CheckedItems1.substr(0,CheckedItems1.length-1);

   count++;

  }

  i++;

 }

}




[php프로그램 부분]

$result=db_query("SELECT * FROM CatalGues WHERE id=$_GET[id]");

$row=db_fetch_assoc($result);




<form name="form2" enctype="multipart/form-data" onSubmit="return caeSubmit(this);">

<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">

<?

$chkcnt=6;

$bunya_item=array("자동차","항공","철도","선박","산업기계","중장비","농기계","전자","건설토목","기타");

$bunya = explode("*", $row["bunya1"]);

  for($i=0; $i<sizeof($bunya_item); $i++) {

        $cnt++;

        $na = intval( $cnt / $chkcnt);

        $first  = ( $na * $chkcnt) + 1;

        $last = ( $na * $chkcnt) + $chkcnt;

        if  ($cnt==$first) {

?>

<tr>

<?

        }

    $chk = 0;

    for($j=0; $j<sizeof($bunya); $j++) {

      if( $bunya[$j]==$bunya_item[$i]) {

?>

<td><input type="checkbox" name="bunya1" value="<?=$bunya_item[$i]?>" checked onFocus="this.blur();"><font color="darkred"><?=$bunya_item[$i]?></font></td>

<?

        $chk = 1;

      }

    }




    if($chk==0) {

?>

<td><input type="checkbox" name="bunya1" value="<?=$bunya_item[$i]?>" onFocus="this.blur();"><?=$bunya_item[$i]?></td>

<?

    }

if ($cnt==$last) {

?>

</tr>

<?

}

  }

?>

</table>

<input type="hidden" name="chkitem1">

</form>


  1. PHP의 유동변수!? - $a1 ~ $a2 같은 형식의 변수를 반복문 돌릴때...

    Date2017.03.06 Views16610
    Read More
  2. PHP웹 보안 취약점 TOP5(웹해킹)

    Date2023.01.12 Views293
    Read More
  3. PHP와 HTML과 자바스크립트의 관계

    Date2021.03.26 Views311
    Read More
  4. PHP에서의 대칭 암호화/복호화 ― 간단한 예제에서 DB 입/출력까지

    Date2018.09.14 Views3548
    Read More
  5. php에서 체크박스 선택한 것 보여주기

    Date2019.01.08 Views1807
    Read More
  6. PHP에서 조건문 처리

    Date2015.04.14 Views22038
    Read More
  7. PHP에서 자바스크립트 값 가져오기

    Date2014.02.27 Views31635
    Read More
  8. PHP에서 자료, 데이터의 타입을 확인하는 방법, gettype()

    Date2018.08.29 Views2465
    Read More
  9. PHP에서 암호화 encrypt 복호화 decrypt 해서 값을 넘기기

    Date2018.02.09 Views10626
    Read More
  10. PHP에서 모든 세션 정보를 화면에 출력하는 방법

    Date2018.08.29 Views2694
    Read More
  11. PHP에서 데이터를 엑셀(Excel)로 저장

    Date2017.02.19 Views18428
    Read More
  12. PHP에서 UTF와 EUC-KR 변환

    Date2019.02.19 Views1554
    Read More
  13. PHP에서 PDF파일 생성하기

    Date2014.02.27 Views32777
    Read More
  14. PHP에서 Excel 파일을 만들 수 있는 PHPExcel

    Date2017.03.06 Views17112
    Read More
  15. PHP에서 CSV 파일 export

    Date2016.04.22 Views22335
    Read More
  16. PHP로 엑셀 자료 MySQL에 넣기

    Date2017.03.06 Views17875
    Read More
  17. PHP로 Excel 파일 만들기...

    Date2014.02.27 Views30257
    Read More
  18. php로 db 컨트롤 1

    Date2017.03.06 Views15769
    Read More
  19. phpMyAdmin WebMysql 에 CSV 엑셀 파일 업로드 입력하기 ( Excel / Upload / data / 데이터 / 데이타 )

    Date2021.03.25 Views760
    Read More
  20. phpexcel을 이용한 PHP로 엑셀파일 읽기와 생성

    Date2017.03.06 Views22787
    Read More
Board Pagination Prev 1 ... 5 6 7 8 9 10 11 12 13 14 ... 17 Next
/ 17

하단 정보를 입력할 수 있습니다

© k2s0o1d4e0s2i1g5n. All Rights Reserved