将php表单数据传输到js窗口 [英] transferring php form data to a js window

查看:147
本文介绍了将php表单数据传输到js窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用javascript和jquery设计一款游戏。在我的游戏中,当玩家与另一个角色交谈时,它会使用 window.open('')函数将文本作为外部文件打开。在游戏开始时,用户必须为他们的角色输入一个名字,然后由php处理:< form action =play.phpmethod =get>

< input type =textname =name/>< input type =submitvalue =confirm/>

< /

正如我之前所说的,当一个玩家与另一个玩家对话时,它会打开外部文件,但我所要求的是如何将表单数据传送到外部窗口打开 window.open('')我已经试过了 function txtone()

{ window.open('txtone.php?name =<?php echo $ _GET [name'];?>')
}

/>但它没有工作,所以基本上我最终想要的是一个外部窗口,用 window.open('txtone.php')打开,可以接收

编辑:我有一个想法,它从打开的页面开始(
而不是打开txtone.php它会打开txtone.php?name = example)。我可以发送一个PHP变量用window.open打开子窗口,但我不知道如何做这个与 window.opener

I am designing a game with javascript and jquery. In my game when a player talks to another character it opens the text as an external file using the window.open('') function. At the beginning of the game the user has to enter a name for their character it is then processed by php:
<form action="play.php" method="get">
<input type="text" name="name"/><input type="submit" value="confirm"/>
</form>
.
As I said before when a player talks to another player it opens the external file but what I am asking is how to transfer the form data to the external window opened with window.open('') I have already tried
function txtone()
{
window.open('txtone.php?name=<?php echo $_GET["name']; ?>')
}

but it didn't work. So basically what I want in the end is an external window opened with window.open('txtone.php') that can receive the php data from the page it was opened from
(rather than opening txtone.php it would open txtone.php?name=example).

I have an idea I could send a php variable to the child window opened with window.open but I have no idea how to do this mabye with window.opener?

推荐答案

您是否试过 window.open('txtone.php?name =<?php echo htmlspecialchars($ _ GET [name]); ?>')

这篇关于将php表单数据传输到js窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆