我在网站上搜索了一个答案,但我尝试过的任何工作都没有。我正在尝试为值" billid"创建一个简单的1字段表单。传递到URL的末尾,但没有运气。 URL会在弹出窗口中打开,但是我无法填充字段值。这是我的代码:
<?php
if(!isset($_POST['submit'])){
$billid = $_POST['bid1'];
?>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" onSubmit="centeredPopup('/plugins/community/statement/statement/statement.php?userid=<?php echo $memid; ?>&billingid=<?php echo $billid; ?>','myWindow','900','750','yes');return false" >
<input type="text" name="bid1">
<input type="submit" name="submit" value="Submit">
</form> <?php } ?>
提前致谢!
答案 0 :(得分:1)
由于您实际上并未提交表单,因此您无法通过PHP传递该信息。您应该使用javascript获取用户输入的信息。以下是一些应该有效的代码:
<?php if (!isset($_POST['submit'])) { ?>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"
onSubmit="centeredPopup('/plugins/community/statement/statement/statement.php?userid=<?php echo $memid; ?>&billingid=' + document.getElementById('bid1').value,'myWindow','900','750','yes');return false">
<input type="text" name="bid1" id="bid1">
<input type="submit" name="submit" value="Submit">
</form> <?php } ?>
答案 1 :(得分:1)
您可以使用this.inputname.value
直接在js中获取输入值:
<form method="post" action="" onSubmit="showPopup(this.bid1.value);return false" >
<input type="text" name="bid1">
<input type="submit" name="submit" value="Submit">
</form>
<script type="application/javascript">
function showPopup(billingId){
centeredPopup(
'/plugins/community/statement/statement/statement.php?userid=<?php echo $memid; ?>&billingid=' + billingId,
'myWindow','900','750','yes'
)
}
</script>
答案 2 :(得分:1)
您不需要使用php。您只能使用JavaScript来获取输入。 你可以这样做:
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" onSubmit="centeredPopup('/plugins/community/statement/statement/statement.php?userid=yourid&billingid=' + this.bid1.value, 'myWindow', '900', '750', 'yes'); return false" >
<input type="text" name="bid1">
<input type="submit" name="submit" value="Submit">
</form>