I have a form which fills the input fields on page load off of MySQL server, but when I try to assign it's value to a JavaScript variable, it crashes.
Here is JS;
function getTotal(e)
{
total = myform2.1.value;
}
It just crashes and here is my html/php;
<?php
include('connect.php');
$id=$_GET['id'];
$result = $db->prepare("SELECT * FROM zones WHERE id= 1");
$result->bindParam('1', $id);
$result->execute();
for($i=0; $row = $result->fetch(); $i++){
?>
<form action="edit.php" method="POST" class="elegant-aero" name="myform2">
<input type="hidden" name="memids" value="<?php echo $id; ?>" />
<br>
<input type="text" name="1" value="<?php echo $row['1']; ?>" /><br>
<br>
<input type="text" name="2" value="<?php echo $row['2']; ?>" /><br>
<br>
<input type="text" name="3" value="<?php echo $row['3']; ?>" /><br>
<input type="button" value="za" id="secret" onclick="getTotal(this)"/>
</form>
<?php
}
?>
Basically I fill the HTML input fields with data from MySQL but the JavaScript variable total
didn't couldn't retrieve the value, although the HTML input field gets the value just fine from the MySQL server via PHP, any thoughts??