以表格形式提交禁用的输入无法获得价值 [英] submit a disabled input in a form could not get value

查看:90
本文介绍了以表格形式提交禁用的输入无法获得价值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

表格如下:

<form action="sendmail.php" method="get">
    <input type="text" name="phone" id="phone" data-clear-btn="true">
    <input type="text" name="name" id="name" data-clear-btn="true">
    <input disabled="disabled" type="text" name="textinput-disabled" id="textinput-disabled" placeholder="Text input" value="<?php echo $info;?>">
</form>

$ info ="type1";并且$ info的格式可以正常工作.

$info = "type1"; and the $info works fine in the form.

但在sendmail.php中

but In the sendmail.php

$name=$_GET['name'];
$type=$_GET['textinput-disabled'];
$phone=$_GET['phone'];

我得到了姓名和电话,但是我无法在禁用textinput的情况下得到该值. 这是什么问题.

I get the name and phone, but I can't get the value in the textinput-disabled. What's the problem here.

推荐答案

未提交禁用字段.您可以将其设置为只读或隐藏,以在提交时获得价值.

Disabled fields are not submitted. You can make it readonly or hidden, to get value when submitted.

<input readonly type="text" name="textinput-disabled" id="textinput-disabled" placeholder="Text input" value="<?php echo $info;?>">

这篇关于以表格形式提交禁用的输入无法获得价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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