选中复选框后,在另一个页面中显示文本框


Display text box in another page after checking a checkbox,

<HTML>
<HEAD>
<TITLE>Document Title</TITLE>
<script>
function c(){}

function test(){
if(document["f1"]["chkGuar"].checked){
document.getElementById("myrow").style.visibility="visible"
}
else{
document.getElementById("myrow").style.visibility="hidden"
}
}
</script>
</HEAD>
<BODY>
<FORM NAME="f1">
<input type="checkbox" name="chkGuar" value="ON" onclick = "c() ; test()">
<div id="myrow" style="visibility:hidden">
<input type = text name ='txtGRTNo' tabindex = 19 size="20"></div>
<div width="338" align="left" colspan="3" height="12"></div>
</FORM>
</BODY>
</HTML>
在此代码中,文本框在同一页面中

打开,但我希望我的文本框显示在另一个页面(通常在操作页面中)。我在一个公共汽车网站上工作,我希望,当用户选中复选框(1 个或多个)以选择座位时,我希望在选中复选框后在下一页中打开任何文本框。

这是您想要的代码。 检查一下,让我知道。

<HTML>
<HEAD>
<TITLE>Document Title</TITLE>
</HEAD>
<BODY>
<FORM NAME="f1" action="next_page.php" method="post">
<input type="checkbox" name="chkGuar[]" value="mike">&nbsp;Mike<br />
<input type="checkbox" name="chkGuar[]" value="joy">&nbsp;Joy<br />
<input type="checkbox" name="chkGuar[]" value="harry">&nbsp;harry<br />
<input type="checkbox" name="chkGuar[]" value="watson">&nbsp;watson<br />
<input type="checkbox" name="chkGuar[]" value="george">&nbsp;george<br />
<input type="checkbox" name="chkGuar[]" value="peter">&nbsp;Peter<br />
<input type="submit" name="chksbmt" value="Send" />
<!-- <div id="myrow" style="visibility:hidden">
<input type = text name ='txtGRTNo' tabindex = 19 size="20">
</div>
<div width="338" align="left" colspan="3" height="12"></div> !-->
</FORM>
</BODY>
</HTML>

next_page.php

<?php
    if(isset($_POST['chksbmt'])){
        $counts = count($_POST['chkGuar']);
        echo "this is the next page. you checked $counts checkbox <br /><br />";
        for($i=1;$i<=$counts;$i++){
        echo "<input type='text' style='border:1px solid #000;' value='your text box here'     
     /><br/><br/>";
        }
    }
嗨,

这是像您的要求一样的代码 试试吧

<HTML>
<HEAD>
<TITLE>Document Title</TITLE>
<script type="text/javascript">
function c(){
    alert("Hi");
    this.f1.submit();
}

function test(){
if(document["f1"]["chkGuar"].checked){
document.getElementById("myrow").style.visibility="visible"
}
else{
document.getElementById("myrow").style.visibility="hidden"
}
}
</script>
</HEAD>
<BODY>
<FORM NAME="f1" action="next_page.php" method="post">
<input type="checkbox" name="chkGuar" value="ON" onclick = "c() ; test()">
<!-- <div id="myrow" style="visibility:hidden">
<input type = text name ='txtGRTNo' tabindex = 19 size="20">
</div>
<div width="338" align="left" colspan="3" height="12"></div> !-->
</FORM>

</BODY>
</HTML>

next_page.php

<?php
if(isset($_POST['chkGuar'])){
    echo "this is the next page. <br />";
    echo "<input type='text' style='border:1px solid #000;' value='your text box here' />";
}

您必须创建获取请求的第二个页面。在第一个路径上,将 for 发布到第二个路径(代码中缺少的操作和方法属性)。

然后根据选中的复选框,在第二页的文本框中显示第一页中所需的内容。

这就是我看到的方式。