如何从javascript到html表单的多个参数

时间:2014-01-16 17:39:16

标签: javascript html forms

这是我正在尝试的代码

<script>
 var output = "<table id='e' border><tr><td><input type='text' id=/"t"/></td><td><input type='text' id=/"t1/"></td><td><input type='text1' id=/"t2"/></td><td><input type='text1' id=/"t3"/></td><button onclick=del('"+ divId +"')>delete</button></td></tr></table>";

</script>

<body>
<form method=post action="t.php">
<input type="text" id= ??(from script...)
</body>

我要做什么shell才能在文本字段中逐个从脚本中发送参数?有可能吗?

2 个答案:

答案 0 :(得分:1)

是的,您可以从输入文本中获取价值:

<input type="text" id"yourIDinput" onchange="YouFunctionJavaScript()"/>

<script>
 function YouFunctionJavaScript(){
  var textInput = $("#yourIDinput").val(); // Here you get value
  alert(textInput); // 

}
</script>

是吗?

答案 1 :(得分:1)

在php中:

<?php 
if($_POST['submit'])
{
    $user = $_POST['user'];
    $pass = $_POST['pass'];
    //Here you have the text in php variables. You can do whatever you want with them
}
?>

<form method="post" enctype="multipart/form-data" name="form">
    Username: <input type="text" name="user" required>
    Password: <input type="password" name="pass" required>
</form>