|
|
|
วิธีอ่าน element ทั้งหมดในหน้าเว็บ เช่น textbox , select , radio ในหน้าเว็บปัจจุบัน |
|
|
|
|
|
|
|
Code (PHP)
<html>
<head>
<title>ThaiCreate.Com Tutorial</title>
<script language="JavaScript">
function fncCheck()
{
var elm;
ele_text = document.frmMain.getElementsByTagName('input');
for( i=0, elm; elm=ele_text.item(i++); )
{
if (elm.getAttribute('type') == "text")
{
alert("elm.name=" + elm.name);
alert("elm.value=" + elm.value);
}
}
ele_hidden = document.frmMain.getElementsByTagName('hidden');
for( i=0, elm; elm=ele_hidden.item(i++); )
{
if (elm.getAttribute('type') == "hidden")
{
alert("elm.name=" + elm.name);
alert("elm.value=" + elm.value);
}
}
ele_textarea = document.frmMain.getElementsByTagName('textarea');
for( i=0, elm; elm=ele_textarea.item(i++); )
{
if (elm.getAttribute('type') == "textarea")
{
alert("elm.name=" + elm.name);
alert("elm.value=" + elm.value);
}
}
ele_select = document.frmMain.getElementsByTagName('select-one');
for( i=0, elm; elm=ele_select.item(i++); )
{
if (elm.getAttribute('type') == "select-one")
{
alert("elm.name=" + elm.name);
alert("elm.value=" + elm.value);
}
}
}
</script>
</head>
<body>
<form name="frmMain" action="" method="post">
Text 1<input type="text" name="txt1" value=""> <br>
Text 2<input type="text" name="txt2" value=""> <br>
<input type="button" name="btnCheck" value="Check" OnClick="fncCheck();">
</form>
</body>
</html>
|
|
|
|
|
Date :
2011-06-09 21:11:16 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|