简体   繁体   English

如何从URL填充textarea?

[英]How can I populate a textarea from a URL?

I am trying to write a script in PHP that can send a message to some user on a forum. 我正在尝试用PHP编写一个脚本,可以在论坛上向某个用户发送消息。 So for example, the message form can be formatted like such: 例如,消息表单可以这样格式化:

<input>Username Goes Here</input

<textarea>Message Goes Here</textarea>

Luckily I am able to populate the input field from how the URL is formatted. 幸运的是,我能够根据URL的格式填充输入字段。 However, I am not so lucky with the textarea part. 但是,我对textarea部分不太满意。

How would I be able to populate the textarea field? 我怎样才能填充textarea字段?

The link is formatted as such: 链接格式如下:

https://live.xbox.com/en-US/Messages?gamertag=gamertag

Where "gamertag" is the recipient “gamertag”是收件人的地方

The textarea is formatted as: textarea格式为:

<textarea class="compose empty" empty="true">Say something here...</textarea>

Thanks for the help! 谢谢您的帮助!

Like this : 像这样 :

<textarea class="compose empty" empty="true"><?php echo htmlspecialchars($_REQUEST['gamertag']);?></textarea>

Considering the url is 考虑到网址是

https://live.xbox.com/en-US/Messages?gamertag=gamertag

You can get the value of gamertag like : 你可以获得gamertag的价值:

$gamertag = htmlspecialchars($_GET['gamertag']);
$gamertag = htmlspecialchars($_REQUEST['gamertag']);

To include static content : 要包含静态内容:

<textarea class="compose empty" empty="true">Your Verification Code is : <?php echo htmlspecialchars($_REQUEST['gamertag']);?></textarea>

Your website can't cause a user's browser to pre-populate arbitrary fields on a third party site. 您的网站无法使用户的浏览器预先填充第三方网站上的任意字段。

Presumably Microsoft provide a mechanism to pre-populate the username field for the purposes of "Contact me" links, but not the message since the positive use cases for that are far fewer and it encourages spammy messages. 据推测,微软提供了一种机制来预先填充用户名字段以用于“联系我”链接,但不是消息,因为正面的用例很少,它鼓励垃圾邮件。

从中填充一个数组<textarea>&lt;i&gt;in JavaScript&lt;/div&gt;&lt;/i&gt;&lt;b&gt;在 JavaScript 中&lt;/div&gt;&lt;/b&gt;</textarea><div id="text_translate"><p> 我将如何从&lt;textarea&gt;输入中的文本填充数组?</p><p> 我的最终目标是获取一个名称列表,然后将其插入到一个数组中以执行一些操作。 名称将由行分隔,如下所示:</p><pre> bob tim sally</pre><p> 然后添加到数组中。 老实说,除了添加&lt;textarea&gt;和创建一个空白数组外,我不知道从哪里开始。 我正在阅读其他帖子,但它们使用的是 jQuery 或我还不知道的其他语言。 我的理解是我必须以某种方式拆分内容?</p></div> - Populate an array from <textarea> in JavaScript

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当 textarea 初始化为 ckeditor 时,我们如何填充 textarea 值 - How can we populate textarea value when textarea is initilized as ckeditor 如何用CSS类填充Textarea? - How Could I Populate a Textarea With a CSS Class? 如何在使用 GET 方法发送 url 时保留 textarea 输入中的文本段落? - How can I preserve the text paragraphs from a textarea input while sending in url with GET method? 如何计算文本区域中的字符? - How can I count the characters from a textarea? 如何阻止文本区域消失? - How can I stop the textarea from disappearing? 从表填充textarea - Populate textarea from table 从文本文件填充textArea - Populate textArea from textfile 为什么我不能用用户的URL填充数组? - Why can't I populate my array with the URL from the user? 从中填充一个数组<textarea>&lt;i&gt;in JavaScript&lt;/div&gt;&lt;/i&gt;&lt;b&gt;在 JavaScript 中&lt;/div&gt;&lt;/b&gt;</textarea><div id="text_translate"><p> 我将如何从&lt;textarea&gt;输入中的文本填充数组?</p><p> 我的最终目标是获取一个名称列表,然后将其插入到一个数组中以执行一些操作。 名称将由行分隔,如下所示:</p><pre> bob tim sally</pre><p> 然后添加到数组中。 老实说,除了添加&lt;textarea&gt;和创建一个空白数组外,我不知道从哪里开始。 我正在阅读其他帖子,但它们使用的是 jQuery 或我还不知道的其他语言。 我的理解是我必须以某种方式拆分内容?</p></div> - Populate an array from <textarea> in JavaScript 如何使用从各个复选框派生的字符串值填充文本区域? - How to populate a textarea with string values derived from various checkboxes?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM