admin管理员组文章数量:1434890
This is for generating the table.
function makeTable()
{
var row_num = 20;
var cell_num = 4;
var tab = document.createElement('table');
tab.setAttribute('id','newtable');
var tbo = document.createElement('tbody');
tbo.setAttribute('id','tabody');
var cont;
for(var c = 0 ; c < row_num ; c++)
{
var row = document.createElement('tr');
for(var k = 0 ; k < cell_num ; k++)
{
var cell = document.createElement('td');
if (k > 0)
{
cont = document.createElement("input");
cont.setAttribute('type','text');
}
else
{
cont = document.createTextNode("0" + (c+1));
}
cell.appendChild(cont);
row.appendChild(cell);
}
tbo.appendChild(row);
}
tab.appendChild(tbo);
document.body.appendChild(tab);
tab.setAttribute("align", "top-left");
}
This function is used to show the data in alert box but I want to retrieve document.getElementById('hide').value............
function GetCellValues()
{
var rows = document.getElementsByTagName('tr');
var str = '';
for (var c = 1 ; c < rows.length ; c++)
{
str += '\n';
var row = rows[c];
var inputs = row.getElementsByTagName('input');
for (var k = 0 ; k < inputs.length ; k++)
{
str += inputs[k].value + ', ';
}
}
document.getElementById('hide').value = str;
I want to retrieve only this hidden control (i.e-"hide") in php.
alert(document.getElementById('hide').value);
}
window.onload = function()
{
makeTable();
};
</script>
</head>
<body>
<h1><u>PROJECT</u> :</h1>
<input type="button" value="Alert" onclick = "GetCellValues()">
I want to retrieve this id in php
<input type="hidden" id="hide" /> <br />
<div id="mytable">
<table id = "project" border = "1" width ="60%" class = "newtable" cellpadding="10" cellspacing="0">
<tr>
<th align="center" width ="200px">Sl.No.</th>
<th align="center" width ="200px">Project Name</th>
<th align="center" width ="200px">ChangeDate</th>
<th align="center" width ="200px">Changed By</th>
</tr>
</table>
</div>
</body>
Note: I want to retrieve the hidden control through id in php ##
I want the total php code to retrieve this hidden control data(i.e-input type="hidden" id="hide"
) because I'm a beginner
This is for generating the table.
function makeTable()
{
var row_num = 20;
var cell_num = 4;
var tab = document.createElement('table');
tab.setAttribute('id','newtable');
var tbo = document.createElement('tbody');
tbo.setAttribute('id','tabody');
var cont;
for(var c = 0 ; c < row_num ; c++)
{
var row = document.createElement('tr');
for(var k = 0 ; k < cell_num ; k++)
{
var cell = document.createElement('td');
if (k > 0)
{
cont = document.createElement("input");
cont.setAttribute('type','text');
}
else
{
cont = document.createTextNode("0" + (c+1));
}
cell.appendChild(cont);
row.appendChild(cell);
}
tbo.appendChild(row);
}
tab.appendChild(tbo);
document.body.appendChild(tab);
tab.setAttribute("align", "top-left");
}
This function is used to show the data in alert box but I want to retrieve document.getElementById('hide').value............
function GetCellValues()
{
var rows = document.getElementsByTagName('tr');
var str = '';
for (var c = 1 ; c < rows.length ; c++)
{
str += '\n';
var row = rows[c];
var inputs = row.getElementsByTagName('input');
for (var k = 0 ; k < inputs.length ; k++)
{
str += inputs[k].value + ', ';
}
}
document.getElementById('hide').value = str;
I want to retrieve only this hidden control (i.e-"hide") in php.
alert(document.getElementById('hide').value);
}
window.onload = function()
{
makeTable();
};
</script>
</head>
<body>
<h1><u>PROJECT</u> :</h1>
<input type="button" value="Alert" onclick = "GetCellValues()">
I want to retrieve this id in php
<input type="hidden" id="hide" /> <br />
<div id="mytable">
<table id = "project" border = "1" width ="60%" class = "newtable" cellpadding="10" cellspacing="0">
<tr>
<th align="center" width ="200px">Sl.No.</th>
<th align="center" width ="200px">Project Name</th>
<th align="center" width ="200px">ChangeDate</th>
<th align="center" width ="200px">Changed By</th>
</tr>
</table>
</div>
</body>
Note: I want to retrieve the hidden control through id in php ##
I want the total php code to retrieve this hidden control data(i.e-input type="hidden" id="hide"
) because I'm a beginner
4 Answers
Reset to default 0You have to add a name to your input so for example:
<input type="hidden" id="hide" name="foo" />
To retrieve the value in php after POST form submission you can do this:
<?php $var1 = $_POST["foo"]; ?>
Can you please replace this line
<input type="hidden" id="hide" />
to
<input type="hidden" id="hide" name="hide" />
and use $_POST["hide"]
in you php script.
Input field must have some name
to access it
<input type="hidden" id="hide" name="hide" />
do normal fetch
$name = $_POST['hide'];
add name property to input type and value you want to get into you php
<input type="hidden" id="hide" name="flag" value="1" />
and to retrieve the value in php after POST form
$var1 = $_POST["flag"];
本文标签: javascriptHow to get the value of html ltinput type“hidden” idquothidequotgt in PHPStack Overflow
版权声明:本文标题:javascript - How to get the value of html <input type=“hidden” id="hide"> in PHP? - Stack Overfl 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745639942a2667793.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论