在发送到 PHP 之前从 HTML Select Tag 读取数据 [英] Read data from HTML Select Tag before sending to PHP

查看:23
本文介绍了在发送到 PHP 之前从 HTML Select Tag 读取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要向 PHP 脚本发送一个选项,但用户只需点击一个类型链接,而不是点击提交按钮.

I need to send a option to a PHP script, but the instead of a user clicking on a submit button, they simply click a type link.

例如:

<select name="test">
   <option value="1">1</option>
</select>
<a href="next.php">Next</a>

因此用户将选择 1,然后单击显示下一步"的链接.这几乎就像我需要在通过 GET 请求 (php.php?select=1) 将它发送到 php 之前阅读 select 标签.有什么想法可以克服这个障碍吗?

So the user will select 1, then click on the link that says "Next". It's almost like i need to read the select tag BEFORE sending it to the php by a GET request (php.php?select=1). Any ideas how I can pass over this roadblock?

推荐答案

You Have to use

tag to make this possible or use ajax submit tu submit your form with <form>你可以这样做

You Have to use <form> tag to make this possible or use ajax submit tu submit your form with <form> you can do in this way

<form action="next.php" method="POST">
 <select name="test">
   <option value="1">1</option>
 </select>
 <!-- Then after this don't use anchor tag <a> use input submit instead-->
<input type="submit" name="submit" value="Next"/>
</form>

或者你也可以用

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