简体   繁体   English

我如何从html输入中添加变量并在从mysql数据中提取的url中显示

[英]How do I add variable from html input and display in a url pulling from mysql data as well

I have a page that is utilizing jquery, mysql and php. 我有一个利用jquery,mysql和php的页面。 In the page I have an input such as below 在页面中,我有如下输入

<input type="text" name="numberid" id="textbox1" value="12345"  />

I am trying to take this info textbox1 and to combine it with a php statement that pulls from a mysql database to create a button redirect to a site. 我正在尝试获取此信息textbox1并将其与从mysql数据库提取的php语句结合起来,以创建重定向到站点的按钮。 I have accomplished the url and pulled the $item but do not know how to attach the textbox1 variable value to the end of url after ?Id= 我已经完成了网址并提取了$ item,但不知道如何在?Id =之后将textbox1变量值附加到网址末尾

           <span style="margin-left:10px;"><a href="http://www.example.com/<?php echo $item?>?Id=textbox1"><input type="button" class="btn btn-info edit" value="Share" style="width:100px; height:50px"  id="<?php echo $id; ?>"name="<?php echo $parent; ?>"></a></span>

Use something like this maybe a class 用这样的东西也许是一堂课

 <a class="pressthis" href="#" data-mhtml="put your html reference here" > 

Then use a function like the following 然后使用如下函数

 $(".pressthis").click(function() { var myhtml = $(this).data('mhtml'); myhtml = myhtml + "&yourtextbox=" + $textbox1.val(); window.location = myhtml }); 

This would allow you to have any number of html links handled by the same function, Obviously if you want to add some id to the end of the html, like the contents of your textbox then just then just add the content of the textbox to the myhtml string 这将允许您使用同一函数处理任意数量的html链接,显然,如果您想在html的末尾添加一些ID,例如文本框的内容,则只需将文本框的内容添加到myhtml字符串

 myhtml = myhtml + "&yourtextbox=" + $textbox1.val(); 

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM