onclick事件的JavaScript / PHP问题

时间:2019-04-18 15:21:40

标签: javascript php syntax-error

如果每次按下按钮时在JavaScript中使用math.rand,它将自动更改为字符串。但是当我使用php代码时,为什么它只更改一次。

我该如何解决?

<input  type="text" id="adminrand" name="tokenid" placeholder="Enter Token" class="form-control" required>

        <?php 
         date_default_timezone_set('Asia/China');
         $tokentime=date('s');
         $tokentime1= date('i');
         $tokentime2=date('m') + date('d')+ date('y') + date('i');
         $token = 'Phcl' .  $tokentime .''. $tokentime1 . '' . $tokentime2;
        ?>

        <button  type="button" onclick="GenerateTokenx()">Generate</button>

        <script>
            function GenerateTokenx() {
                let r = Math.random().toString(36).substring(5);
                document.getElementById("adminrand").value ='<?php echo$token;?>';  
            }
        </script>

0 个答案:

没有答案