- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
您好,我正在编写代码来获取文本框的值。尽管所有其他值都打印得很好,但 alert(FormID) 打印为未定义。在这里,我已经清楚地评论了我得到的东西。请有人帮助我指出我所犯的错误。
<html>
<title></title>
<head>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script></head>
<script src="UserTypeSubmit.js"></script></head>
<script>
$(document).ready(function(){
$(".FormEdit").click(function(){
var B=$(this).attr('id');// Ex: Getting ID as FormEdit1 if click on first Edit link
var ReplacesVal=B.replace("FormEdit","");//Prints Value as 1 a I I need.
alert("FormIDInput"+ReplacesVal);//Alert : FormIDInput1
var FormID=$("#FormIDInput"+ReplacesVal).val();
alert(FormID);// Alert: Undefine. Im expecting the value 1 to be in the alert as $("#FormIDInput"+ReplacesVal).val() is equal to 1. and it prints well in the text box.
});
return false;
});
</script>
</head>
<body>
<div class="User" style="color:#0B173B">Forms_Available_to_Collect_Pubic_Health_Information </div>
<br><br>
<?php
include 'connectionPHP.php';
$result=mysqli_query($con,"SELECT * FROM Form");
echo "<table border='1' id='DisplayFormDetailss'>
<tr style='background-color:#D0A9F5;' height='40px;'>
<th width='100px;'>Form ID</th>
<th width='420px;'>Form Name</th>
<th width='100px;'>Inactivate</th>
<th width='70px;'>Edit</th>
<th width='70px;'>Delete</th>
<th width='70px;'>Save</th>
</tr>";
$i=1;
while($row = mysqli_fetch_array($result))
{
$w=$row['Form_ID'];
$v=$row['Form_Name'];
echo "<tr height='25px;'>";
echo "<input id='FormIDInput ".$i."' value='$w' ></input>";
//Prints 1,2,3,4,5,6 as the values of input boxes perfectly.
echo "<td name='FormID[]' class='FormID' align='center' value='$w'>$w</td>";
echo "<td name='FormName[]' id='FormName".$i."' align='left'>$row[Form_Name]</td>";
echo "<td name='FormInactive[]' id='FormInactive".$i."' align='center'><input type='checkbox'></input></td>";
echo "<td class='FormEdit' id='FormEdit".$i."' align='center'><a href='' align=left>Edit</a></td>";
echo "<td name='FormDelete[]' id='FormDelete".$i."' align='center'><a href='' align=left>Delete</td>";
echo "<td name='FormSave[]' id='FormSave".$i."' align='center'><a href='' align=left>Save</td>";
echo "</tr>";
$i++;
}
echo "</table>";
?>
</body>
</html>
最佳答案
在你的PHP代码中,输入框中有一个空格:
echo "<input id='FormIDInput ".$i."' value='$w' ></input>";
尝试将其替换为
echo "<input id='FormIDInput".$i."' value='$w' ></input>";
关于javascript - 文本框的值打印为 Undefined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20438464/
我只是有一个更琐碎的问题。 为什么undefined == undefined 返回true,而undefined >= undefined 为false? undefined 等于 undefine
用PHP 7.2编写套接字服务器。根据Firefox 60中的“网络”选项卡,服务器的一些HTTP响应的第一行随机变为undefined undefined undefined。因此,我尝试记录套接字
在 JavaScript 中这是真的: undefined == undefined 但这是错误的: undefined <= undefined 起初我以为<=运算符包含第一个,但我猜它试图将其转换
在回答这个问题 (Difference between [Object, Object] and Array(2)) 时,我在 JavaScript 数组中遇到了一些我以前不知道的东西(具有讽刺意味的
来自https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/of , Note: thi
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
当我添加 到我的 PrimeFaces Mobile 页面,然后我在服务器日志中收到以下警告 WARNING: JSF1064: Unable to find or serve resource, u
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我是一名优秀的程序员,十分优秀!