찾다

 >  Q&A  >  본문

javascript - 제출 후 PHP 체크박스 양식을 새로 고칠 때 선택한 상태를 저장하는 방법

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

<code><!doctype html>

 

<!--?php

//먼저 여기에 관련 호출 코드를 작성합니다.

 

 

$코인 = 1280;

$돈 = 1121;

$coinsale = $coin / 100;

if ( $_POST[ "코인" ] != 0 ) {

    $money -= $coinsale;

 

}

 

?>

<html>

 

<머리>

    <meta charset="utf-8">

    <title>제목 없는 문서</title>

</머리>

 

 

 

<본문>

 

    <form id="form1" name="form1" action="test.php" method="post">

        <input id="coin" name="coin" type="checkbox" value="<?php echo($coinsale)?>" onclick="checkboxOnclick(this)">Tuotecoin

 

        <input id="sale" type="hidden" value="<?php echo($money)?>">

        <input id="asd" type="hidden" value="<?php echo($coinsale)?>">

        <p id="npay" style="width:100%;height:95px;line-height:50px;font-weight:800;font-size:14px;color:red; text-align:center">

            

            <?php 에코 $money ?>

        </p>

        <input type="hidden" id="goodsmoney" name="goodsmoney" value="<?php echo $money; ?>"/>

    </양식>

 

</body>

<스크립트>

     

 

            함수 checkboxOnclick( checkbox ) {

 

                var products = document.getElementById( "npay" );

                var m = document.getElementById( "sale" ).value;

                var c = document.getElementById( "asd" ).value;

                var f = document.getElementById( "form1" );

                if (checkbox.checked == true) {

 

                    m -= c;

                    goods.innerHTML = "엔" + m;

                    f.제출();

                } 또 다른 {

                    goods.innerHTML = "엔" + m;

                     

                }

            }

    <!--$.("input[type='checkbox']:checked")-->

         

     

</스크립트>

 

</html>

</code--></code>

저는 구체적인 구현을 모르고 PHP에도 익숙하지 않은데 간단한 예를 들어주셨으면 좋겠습니다. 모두 감사합니다 :)

曾经蜡笔没有小新曾经蜡笔没有小新2853일 전435

모든 응답(2)나는 대답할 것이다

  • PHP中文网

    PHP中文网2017-05-16 13:08:30

    1. 양식을 제출한 후 컨트롤러에서 값을 가져와 다시 전달할 수 있습니다

    2. 고정 위치 저장, 예: 선택한 값인 쿠키를 저장하려면 페이지에 숨겨진 태그를 추가하세요

    3. 페이지를 새로 고치지 말고 ajax를 사용하여 값을 전달하세요

    4. 페이지에 iframe을 넣고, iframe에 양식을 복사하여 제출하세요

    회신하다
    0
  • 天蓬老师

    天蓬老师2017-05-16 13:08:30

    $.("input[type='checkbox']:checked") 값을 가져온 후 쿠키에 넣을 수 있습니다. 페이지를 새로 고칠 때마다 먼저 쿠키에서 값을 가져온 다음 .each를 사용하세요. 효과를 반복하려면

    회신하다
    0
  • 취소회신하다