PHP JavaScript onchange 未捕获的错误
PHP JavaScript uncaught error with onchange
我有下拉列表,当有人选择我需要提交的内容时,这是我的代码:
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<body bgcolor="#E2E2E2">
<form action='index.php' method='post' enctype='multipart/form-data' id='myform'>
<div div style="position: absolute;left: 35%; top: 30%;">
<link rel="stylesheet" type="text/css" href="CSS.css">
<?php
include ("config.php");
// Create connection
//form start
if ($result->num_rows > 0) {
// output data of each row
echo"<tr><td>формат: ";
echo"<select class='format' name='formater'onchange='document.getElementById('myform').submit()'>";
while($row = $result->fetch_assoc()) {
echo "<option value='". $row["$formatPrice"]. "'>".$row["$formatColumn"]. "</option>";
}
}
if(isset($_POST['submit'])){
echo "aaa";
}
?>
当我选择选项时出现错误:Uncaught TypeError: object is not a function onchange
感谢您的帮助。
此处呈现html:
<html><head><meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head><body bgcolor="#E2E2E2">
<form action="client.php" method="post" enctype="multipart/form-data" id="myform">
<div div="" style="position: absolute;left: 35%; top: 30%;">
<link rel="stylesheet" type="text/css" href="CSS.css">
<table border="1px" class="table"><tbody><tr><td>Calculator </td></tr> <tr><td>ფორმატი: <select class="format" name="formater" onchange="document.getElementById(" myform').submit()'=""><option value="0.15">A3</option><option value="0.1">A4</option><option value="0.05">A5</option><option value="0.035">A4/3</option>aaa</select></td> </tr><tr><td><input type="submit" name="submit" class="btn" value="Submit"></td> </tr>
</tbody></table></div></form></body></html>
所以在将这个问题标记为重复后,Quentin 向我展示了这个 link "Submit is not a function" error in JavaScript
是的,这绝对是另一回事,这些答案对我没有帮助,我认为它在 PHP 中比在 js 中更多,因为我在没有 PHP 的情况下尝试了这段代码并且它有效......现在我是对此越来越困惑!
我会给表单一个 ID 以便于识别它
<form action='index.php' method='post' id='myform' enctype='multipart/form-data'>
然后将其用于您的 onchange 事件
onchange='document.getElementById("myform").submit()'
我不确定你的格式是否有问题。尝试...
<form action="index.php" method="post" id="myform" enctype="multipart/form-data">
<?php
echo "<select class=\"format\" name=\"formater\" onchange=\"document.getElementById('myform').submit()\">";
while($row = $result->fetch_assoc()) {
echo "<option value=\"" . $row['$formatPrice'] . "\">" . $row['$formatColumn'] . "\"</option>";
}
?>
我有下拉列表,当有人选择我需要提交的内容时,这是我的代码:
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<body bgcolor="#E2E2E2">
<form action='index.php' method='post' enctype='multipart/form-data' id='myform'>
<div div style="position: absolute;left: 35%; top: 30%;">
<link rel="stylesheet" type="text/css" href="CSS.css">
<?php
include ("config.php");
// Create connection
//form start
if ($result->num_rows > 0) {
// output data of each row
echo"<tr><td>формат: ";
echo"<select class='format' name='formater'onchange='document.getElementById('myform').submit()'>";
while($row = $result->fetch_assoc()) {
echo "<option value='". $row["$formatPrice"]. "'>".$row["$formatColumn"]. "</option>";
}
}
if(isset($_POST['submit'])){
echo "aaa";
}
?>
当我选择选项时出现错误:Uncaught TypeError: object is not a function onchange 感谢您的帮助。
此处呈现html:
<html><head><meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head><body bgcolor="#E2E2E2">
<form action="client.php" method="post" enctype="multipart/form-data" id="myform">
<div div="" style="position: absolute;left: 35%; top: 30%;">
<link rel="stylesheet" type="text/css" href="CSS.css">
<table border="1px" class="table"><tbody><tr><td>Calculator </td></tr> <tr><td>ფორმატი: <select class="format" name="formater" onchange="document.getElementById(" myform').submit()'=""><option value="0.15">A3</option><option value="0.1">A4</option><option value="0.05">A5</option><option value="0.035">A4/3</option>aaa</select></td> </tr><tr><td><input type="submit" name="submit" class="btn" value="Submit"></td> </tr>
</tbody></table></div></form></body></html>
所以在将这个问题标记为重复后,Quentin 向我展示了这个 link "Submit is not a function" error in JavaScript 是的,这绝对是另一回事,这些答案对我没有帮助,我认为它在 PHP 中比在 js 中更多,因为我在没有 PHP 的情况下尝试了这段代码并且它有效......现在我是对此越来越困惑!
我会给表单一个 ID 以便于识别它
<form action='index.php' method='post' id='myform' enctype='multipart/form-data'>
然后将其用于您的 onchange 事件
onchange='document.getElementById("myform").submit()'
我不确定你的格式是否有问题。尝试...
<form action="index.php" method="post" id="myform" enctype="multipart/form-data">
<?php
echo "<select class=\"format\" name=\"formater\" onchange=\"document.getElementById('myform').submit()\">";
while($row = $result->fetch_assoc()) {
echo "<option value=\"" . $row['$formatPrice'] . "\">" . $row['$formatColumn'] . "\"</option>";
}
?>