如何在js中使用按钮获取while循环中的值?
def connect(p_str, autocommit=False, ansi=False, timeout=0, **kwargs): # real signature unknown; restored from __doc__
"""
connect(str, autocommit=False, ansi=False, timeout=0, **kwargs) --> Connection
Accepts an ODBC connection string and returns a new Connection object.
**The connection string will be passed to SQLDriverConnect, so a DSN connection
can be created using:**
**cnxn = pyodbc.connect('DSN=DataSourceName;UID=user;PWD=password')**
To connect without requiring a DSN, specify the driver and connection
information:
DRIVER={SQL Server};SERVER=localhost;DATABASE=testdb;UID=user;PWD=password
Note the use of braces when a value contains spaces. Refer to SQLDriverConnect
documentation or the documentation of your ODBC driver for details.
The connection string can be passed as the string `str`, as a list of keywords,
or a combination of the two. Any keywords except autocommit, ansi, and timeout
(see below) are simply added to the connection string.
connect('server=localhost;user=me')
connect(server='localhost', user='me')
connect('server=localhost', user='me')
The DB API recommends the keywords 'user', 'password', and 'host', but these
are not valid ODBC keywords, so these will be converted to 'uid', 'pwd', and
'server'.
pass
谢谢
答案 0 :(得分:1)
单击按钮可以获得文本框的值。
<input type="text" name="sample[]" value="abc" class="valueInput">
<input type="text" name="sample[]" value="xyz" class="valueInput">
<input type="text" name="sample[]" value="pqr" class="valueInput">
<input type="button" class="getValue" value="Get Value">
注意:我已经设置了静态输入框,可以将其设为动态,但请确保将类添加为valueInput。
jQuery代码。
$(document).on('click','.getValue',function(){
var valArr = [];
$(".valueInput").each(function(){
valArr.push($(this).val());
});
console.log(valArr);
})
答案 1 :(得分:0)
输入字段的名称应使用[]表示一个数组。
<form action="action.php" method="POST">
<?php
while ($row = mysqli_fetch_array($query)){
echo '<input type="text" name="sample[]" value="'.$row['sample'].'">';
}
?><input type="submit">
</form>
action.php :(处理提交时的数据)
<?php
echo "<pre>";
print_r($_POST['sample']);
echo "</pre>";