I added the data to mysql but its not true. There are a few lines manually duplicating data. Add and commands my update it still works.I don't understand why the data added to the unsatisfactory. Who can help me not? thanks
this is code html:
<form id="myform" method="post">
<div>
<div>
<div>
<!--dongggggggggggggggggg 2-->
<?php
$select = mysql_query("Select * from Salary where code='C'");
$resultmax = mysql_query("SELECT MAX(stt) AS max_page FROM Salary where code='C'");
$rowmax = mysql_fetch_array($resultmax);
while ($resultRow = mysql_fetch_array($select)) {
?>
<div class="row">
<div class="col-lg-12">
<input type="text" name="stt[]"
value="<?php echo $resultRow['stt'] ?>"
style="float:left; width:20px; border:none"
readonly/>
<input type="hidden" name="d[]" value="C"
style="float:left; width:20px; border:none"/>
<input id="dd" name="a[]" class="col-lg-35 a"
value="<?php echo $resultRow['col_a'] ?>"
type="text">
<input name="b[]" class="col-lg-35 a nhay"
value="<?php echo $resultRow['col_b'] ?>"
onblur="luu()" type="text">
<input name="c[]" class="col-lg-35 a"
value="<?php echo $resultRow['col_c'] ?>"
onblur="luu()" type="text">
<input name="check_save" class="col-lg-1" type="checkbox"
value="" onclick="return false;">
</div>
</div>
<?php } ?>
<div class="row">
<div class="col-lg-12">
<input type="hidden" name="d[]" value="C"
style="float:left; width:20px; border:none"/>
<input name="stt[]"
value="<?php echo $rowmax["max_page"] + 1 ?>"
style="float:left; width:20px;border:none" readonly/>
<input id="dd" name="a[]" class="col-lg-35 a" value=""
type="text">
<input name="b[]" class="col-lg-35 a"
onblur="luu()" value="" type="text">
<input name="c[]" class="col-lg-35 a"
onblur="luu()" value="" type="text">
<input id="save" name="check_save" class="col-lg-1 ab"
type="checkbox" value="" onclick="return false;">
</div>
</div>
<div class="row" id="c">
<div class="col-lg-12">
<input type="hidden" name="d[]" value="C"
style="float:left; width:20px; border:none"/>
<input name="stt[]" id="stt"
value="<?php echo $rowmax["max_page"] + 2 ?>"
style="float:left; width:20px;border:none" readonly/>
<input id="dd" name="a[]" class="col-lg-35 a" value=""
type="text" >
<input name="b[]" class="col-lg-35 a nhay"
onblur="luu()" value="" type="text">
<input name="c[]" class="col-lg-35 a"
onblur="luu()" value="" type="text">
<input id="save" name="check_save" class="col-lg-1 ab"
type="checkbox" value="" onclick="return false;">
</div>
</div>
<!--dongggggggggggggggggg 1-->
<br>
</div>
</div>
</div>
<div>
<di>
<div>
<!--dongggggggggggggggggg 1-->
<?php
$select = mysql_query("Select * from Salary where code='P'");
$resultmax = mysql_query("SELECT MAX(stt) AS max_page FROM Salary where code='P'");
$rowmax = mysql_fetch_array($resultmax);
while ($resultRow = mysql_fetch_array($select)) {
?>
<!--dongggggggggggggggggg 1-->
<!--dongggggggggggggggggg 2-->
<div class="row">
<div class="col-lg-12">
<input type="text" name="stt[]"
value="<?php echo $resultRow['stt'] ?>"
style="float:left; width:20px; border:none"
readonly/>
<input type="hidden" name="d[]" value="P"
style="float:left; width:20px; border:none"/>
<input id="dd" name="a[]" class="col-lg-35 a"
value="<?php echo $resultRow['col_a'] ?>"
type="text">
<input name="b[]" class="col-lg-35 a nhay"
value="<?php echo $resultRow['col_b'] ?>"
onblur="luu()" type="text">
<input name="c[]" class="col-lg-35 a"
value="<?php echo $resultRow['col_c'] ?>"
onblur="luu()" type="text">
<input name="check_save" class="col-lg-1" type="checkbox"
value="" onclick="return false;">
</div>
</div>
<?php } ?>
<div class="row">
<div class="col-lg-12">
<input type="hidden" name="d[]" value="P"
style="float:left; width:20px; border:none"/>
<input name="stt[]"
value="<?php echo $rowmax["max_page"] + 1 ?>"
style="float:left; width:20px;border:none" readonly/>
<input name="a[]" class="col-lg-35 a" value="" type="text">
<input name="b[]" class="col-lg-35 a" value="" onblur="luu()" type="text">
<input name="c[]" class="col-lg-35 a" value=""
onblur="luu()" type="text">
<input id="save" name="check_save" class="col-lg-1 ab" type="checkbox" value="" onclick="return false;">
</div>
</div>
<!--dongggggggggggggggggg 1-->
<!--dongggggggggggggggggg 2-->
<div class="row" id="d">
<div class="col-lg-12">
<input type="hidden" name="d[]" value="P" style="float:left; width:20px; border:none"/>
<input name="stt[]" value="<?php echo $rowmax["max_page"] + 2 ?>" style="float:left; width:20px;border:none" readonly/>
<input id="dd" name="a[]" class="col-lg-35 a" value="" type="text">
<input name="b[]" class="col-lg-35 a nhay" value="" onblur="luu()" type="text">
<input name="c[]" class="col-lg-35 a" value="" onblur="luu()" type="text">
<input id="save" name="check_save" class="col-lg-1 ab" type="checkbox" value="" onclick="return false;">
</div>
</div>
<!--dongggggggggggggggggg 1-->
<br>
</div>
</di>
</div>
</form>
this is javascript :
<script type="text/javascript" language="javascript">
function luu() {
$.ajax({
type: 'POST',
url: 'insert.php',
data: $('#myform').serialize(),
dataType: 'JSON',
success: function (data) {
check();
}
});
}
$(document).ready(function () {
var currentBoxNumber = 0;
$(document).on('keyup', '.a', function (e) {
if (e.keyCode == 13) {
textboxes = $("input.a");
currentBoxNumber = textboxes.index(this);
if (textboxes[currentBoxNumber + 1] != null) {
nextBox = textboxes[currentBoxNumber + 1];
if (nextBox.id == "dd") {
luu();
}
nextBox.focus();
return false;
}
}
});
var i = document.getElementById("stt").value;
$(document).on('keyup', '.nhay', function (e) {
if (e.keyCode == 13) {
$('.a').removeClass('nhay');
var y = parseInt(i) + parseInt(1);
$('#c').append('<div><input type="hidden" name="d[]" value="C" style="float:left; width:20px; border:none"/><input name="stt[]" value="' + y + '" style="float:left; width:20px;border:none" readonly/><input id="dd" name="a[]" class="col-lg-35 a" value="" type="text"><input name="b[]" onblur="luu()" class="col-lg-35 a nhay" value="" type="text"><input name="c[]" onblur="luu()" class="col-lg-35 a" value="" type="text" ><input id="save" name="check_save" class="col-lg-1 ab" type="checkbox" value="" onclick="return false;"></div>');
$('#d').append('<div><input type="hidden" name="d[]" value="P" style="float:left; width:20px; border:none"/><input name="stt[]" value="' + y + '" style="float:left; width:20px;border:none" readonly/><input id="dd" name="a[]" class="col-lg-35 a" value="" type="text"><input name="b[]" onblur="luu()" class="col-lg-35 a nhay" value="" type="text"><input name="c[]" onblur="luu()" class="col-lg-35 a" value="" type="text" ><input name="check_save" class="col-lg-1 ab" type="checkbox" value="" onclick="return false;"></div>');
i++;
}
});
});
<script>
function check() {
var myForm = document.forms.myform;
var myControls = $(myForm).find('input[name="a[]"]').filter(function () {
if (!$.trim(this.value)) {
$(this).siblings('.ab').prop('checked', false)
} else {
$(this).siblings('.ab').prop('checked', true)
}
});
}
this is insert.php :
$a=$_POST['a'];
$b=$_POST['b'];
$c=$_POST['c'];
$sott=$_POST['stt'];
$d=$_POST['d'];
$index=0;
foreach($a as $s){
$check="Select ID from Salary where stt='".$sott[$index]."' and code='".$d[$index]."'";
$result1 = mysql_query($check);
$myid = mysql_num_rows($result1);
if ($myid==null)
{
$sql = "INSERT INTO Salary(code,col_a,col_b,col_c,stt) VALUES('".$d[$index]."','$s','".$b[$index]."','".$c[$index]."','".$sott[$index]."')";
$result = mysql_query($sql);
}
else
{
$sql="Update Salary set col_a='$s',col_b='".$b[$index]."',col_c='".$c[$index]."' where stt='".$sott[$index]."' and code='".$d[$index]."'";
$result = mysql_query($sql);
}
$index++;
}
if ($result) { echo "1";}
this is output :
Related
i would like input from my user to go into a database, but it is not working. I have a working block of sql code that would insert the data into the database, but i keep getting "undefined" errors when it gets ran.
This is the fully working sql code
<?php
require 'creationlink.php';
$quizname = $_POST['name'];
$quest = $_POST['question'];
$ans1 = $_POST['answer1'];
$ans2 = $_POST['answer2'];
$ans3 = $_POST['answer3'];
$ans4 = $_POST['answer4'];
$correct = $_POST['A'];
//initiates connection with database with creation file
$sql = "INSERT INTO Quiz(question, answer1, answer2, answer3, answer4, correct) VALUES (?, ?, ?, ?, ?, ?)";
if($stmt = mysqli_prepare($conn, $sql)){
// Bind variables to the prepared statement as parameters
mysqli_stmt_bind_param($stmt, "ssssss", $quest, $ans1, $ans2, $ans3, $ans4, $correct);
// Attempt to execute the prepared statement
if(mysqli_stmt_execute($stmt)){
echo "Records inserted successfully.";
} else{
echo "ERROR: Could not execute query: $sql. " . mysqli_error($conn);
}
}
else{
echo "ERROR: Could not prepare query: $sql. " . mysqli_error($conn);
}
?>
and this is the code that i would like the sql to apply to, which is just a simple quiz template that iterates depending on the user input.
<html>
<body>
<form id='namennumber' action="includes/dbquestions.php" method="post">
<label for="quizname"><b>Quiz name</b></label>
<input name="quizname" type="text" placeholder="Enter quizname" required>
<div id="myHTMLWrapper">
</div>
</form>
<div style="border:solid 1px #ddd; padding:10px; display:none;" id="cont">
<div id="questionform" class="modal">
<label for="question"><b>Enter a question</b></label>
<input name="question" type="text" placeholder="Enter a question" value ="question" required>
<br>
<label for="answer1">Possible answer A</label>
<input type="text" name="answer1" placeholder="Enter a possible answer" value ="answer1"required>
<br>
<label for="answer2">Possible answer B</label>
<input type="text" name="answer2" placeholder="Enter a possible answer" value ="answer2"required>
<br>
<label for="answer3">Possible answer C</label>
<input type="text" name="answer3" placeholder="Enter a possible answer" value ="answer3"required>
<br>
<label for="answer4">Possible answer D</label>
<input type="text" name="answer4" placeholder="Enter a possible answer" value ="answer4"required>
<br>
<h3>Correct answer</h3>
<br>
<input type="radio" name="A" <?php if (isset($answer) && $answer=="A") echo "checked"; ?> value="A" />
<label for="A">A</label>
<br>
<input type="radio" name="A" <?php if (isset($answer) && $answer=="B") echo "checked"; ?> value="B" />
<label for="B">B</label>
<br>
<input type="radio" name="A" <?php if (isset($answer) && $answer=="C" )echo "checked"; ?> value="C" />
<label for="C">C</label>
<br>
<input type="radio" name="A" <?php if (isset($answer) && $answer=="D" )echo "checked"; ?> value="D"/>
<label for="D">D</label>
<br>
<form action="includes/dbquestions.php">
<button style="width:auto;" id="enter" class="btn btn-primary big-btn" >Save</button>
</form>
</div>
</div>
<script>
var wrapper = document.getElementById("myHTMLWrapper");
var number = prompt("Enter the number of questions");
var myHTML = '';
for (var i = 0; i < number; i++) {
myHTML += '<span class="test">Question ' + (i + 1)
myHTML += '<input type="button" value="Content" id="bt" onclick="toggle(\'cont\')">' +
'</span><br/><br/>';
}
wrapper.innerHTML = myHTML
function toggle(cont) {
var cont = document.getElementById('cont');
if (cont.style.display == 'block') {
cont.style.display = 'none';
document.getElementById(ele.id).value = 'Show DIV';
}
else {
cont.style.display = 'block';
document.getElementById(ele.id).value = 'Hide DIV';
}
};
</script>
</div>
</body>
In your HTML, all the <input> elements are outside the <form> and hence you are getting the undefined error. To resolve the error move your <input> elements to the <form> tag. Try replacing your html code as below.
<html>
<body>
<form id='namennumber' action="includes/dbquestions.php" method="post">
<label for="quizname"><b>Quiz name</b></label>
<input name="quizname" type="text" placeholder="Enter quizname" required>
<div id="myHTMLWrapper">
</div>
</form>
<div style="border:solid 1px #ddd; padding:10px; display:none;" id="cont">
<div id="questionform" class="modal">
<form action="includes/dbquestions.php"> //moved all the input elements
<label for="question"><b>Enter a question</b></label>
<input name="question" type="text" placeholder="Enter a question" value="question" required>
<br>
<label for="answer1">Possible answer A</label>
<input type="text" name="answer1" placeholder="Enter a possible answer" value="answer1" required>
<br>
<label for="answer2">Possible answer B</label>
<input type="text" name="answer2" placeholder="Enter a possible answer" value="answer2" required>
<br>
<label for="answer3">Possible answer C</label>
<input type="text" name="answer3" placeholder="Enter a possible answer" value="answer3" required>
<br>
<label for="answer4">Possible answer D</label>
<input type="text" name="answer4" placeholder="Enter a possible answer" value="answer4" required>
<br>
<h3>Correct answer</h3>
<br>
<input type="radio" name="A" <?php if (isset($answer) && $answer=="A") echo "checked"; ?> value="A" />
<label for="A">A</label>
<br>
<input type="radio" name="A" <?php if (isset($answer) && $answer=="B") echo "checked"; ?> value="B" />
<label for="B">B</label>
<br>
<input type="radio" name="A" <?php if (isset($answer) && $answer=="C" )echo "checked"; ?> value="C" />
<label for="C">C</label>
<br>
<input type="radio" name="A" <?php if (isset($answer) && $answer=="D" )echo "checked"; ?> value="D" />
<label for="D">D</label>
<br>
<button style="width:auto;" id="enter" class="btn btn-primary big-btn">Save</button>
</form>
</div>
</div>
<script>
var wrapper = document.getElementById("myHTMLWrapper");
var number = prompt("Enter the number of questions");
var myHTML = '';
for (var i = 0; i < number; i++) {
myHTML += '<span class="test">Question ' + (i + 1)
myHTML += '<input type="button" value="Content" id="bt" onclick="toggle(\'cont\')">' +
'</span><br/><br/>';
}
wrapper.innerHTML = myHTML
function toggle(cont) {
var cont = document.getElementById('cont');
if (cont.style.display == 'block') {
cont.style.display = 'none';
document.getElementById(ele.id).value = 'Show DIV';
} else {
cont.style.display = 'block';
document.getElementById(ele.id).value = 'Hide DIV';
}
};
</script>
</body>
</html>
As a note, you are using the same parameter for action, for both the <form>s in your HTML. See below.
action="includes/dbquestions.php"
Since you are using $_POST in your server side code, you will have to specify method as post for your <form>, as the default method for a <form> is get and not post.
UPDATE
From your errors, that you have posted in the comments, I've combined the 2 forms that you were using.
<html>
<body>
<form id='namennumber' action="includes/dbquestions.php" method="post">
<label for="quizname"><b>Quiz name</b></label>
<input name="quizname" type="text" placeholder="Enter quizname" required>
<div id="myHTMLWrapper">
</div>
<div style="border:solid 1px #ddd; padding:10px; display:none;" id="cont">
<div id="questionform" class="modal">
<label for="question"><b>Enter a question</b></label>
<input name="question" type="text" placeholder="Enter a question" value="question" required>
<br>
<label for="answer1">Possible answer A</label>
<input type="text" name="answer1" placeholder="Enter a possible answer" value="answer1" required>
<br>
<label for="answer2">Possible answer B</label>
<input type="text" name="answer2" placeholder="Enter a possible answer" value="answer2" required>
<br>
<label for="answer3">Possible answer C</label>
<input type="text" name="answer3" placeholder="Enter a possible answer" value="answer3" required>
<br>
<label for="answer4">Possible answer D</label>
<input type="text" name="answer4" placeholder="Enter a possible answer" value="answer4" required>
<br>
<h3>Correct answer</h3>
<br>
<input type="radio" name="A" <?php if (isset($answer) && $answer=="A") echo "checked"; ?> value="A" />
<label for="A">A</label>
<br>
<input type="radio" name="A" <?php if (isset($answer) && $answer=="B") echo "checked"; ?> value="B" />
<label for="B">B</label>
<br>
<input type="radio" name="A" <?php if (isset($answer) && $answer=="C" )echo "checked"; ?> value="C" />
<label for="C">C</label>
<br>
<input type="radio" name="A" <?php if (isset($answer) && $answer=="D" )echo "checked"; ?> value="D" />
<label for="D">D</label>
<br>
<button style="width:auto;" id="enter" class="btn btn-primary big-btn">Save</button>
</form>
</div>
</div>
<script>
var wrapper = document.getElementById("myHTMLWrapper");
var number = prompt("Enter the number of questions");
var myHTML = '';
for (var i = 0; i < number; i++) {
myHTML += '<span class="test">Question ' + (i + 1)
myHTML += '<input type="button" value="Content" id="bt" onclick="toggle(\'cont\')">' +
'</span><br/><br/>';
}
wrapper.innerHTML = myHTML
function toggle(cont) {
var cont = document.getElementById('cont');
if (cont.style.display == 'block') {
cont.style.display = 'none';
document.getElementById(ele.id).value = 'Show DIV';
} else {
cont.style.display = 'block';
document.getElementById(ele.id).value = 'Hide DIV';
}
};
</script>
</body>
</html>
I want form to be loop by how many checkboxes are checked. Like if for each color what sizes are available. But having some issues. For each checkbox I check It's implementing on all color arrays like in the picture what am looking for
form page
<form method="post" action="submit.php">
ID:<input type="text" name="id" />
Name:<input type="text" name="product" />
<div class="form-group fieldGroup">
<div class="input-group">
Color : <input type="text" name="color[]" id="color">
X <input type="checkbox" name="size[]" id="size" value="X" >
XL <input type="checkbox" name="size[]" id="size" value="XL">
S <input type="checkbox" name="size[]" id="size" value="S">
M <input type="checkbox" name="size[]" id="size" value="M">
<span class="glyphicon glyphicon glyphicon-plus" aria-hidden="true"></span> Add
</div>
</div>
<input type="submit" name="submit" class="btn btn-primary" value="SUBMIT"/>
</form>
submit.php code
if(isset($_POST['submit'])){
$colorArray = $_POST['color'];
$sizeArray = $_POST['size'];
$product = $_POST['product'];
$sl = 1;
$id = $_POST["id"];
$product = $_POST["product"];
if(!empty($colorArray)){
for($i = 0; $i < count($colorArray); $i++){
if(!empty($colorArray[$i])){
foreach ($sizeArray as $x ){
$color = $colorArray[$i];
echo "<h2>" .$sl."> Name : ". $product ." > ".$id ." > ". $color .">" .$x ."</h2>";
$sl++;
}
}
}
}
}
I just cloned one div using jQuery clone, how can I rename each div elements id, and value after cloning, below is my code,
jQuery(function(){
jQuery('#act').click(function(){
jQuery("#test").clone(true, true).insertAfter("div#test:last");
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="test" class="test">
<input type="hidden" name="product" value="<?php /* #escapeNotVerified */ echo $_product->getId() ?>" />
<input type="hidden" name="selected_configurable_option" value="" />
<input type="hidden" name="related_product" id="related-products-field" value="" />
<label class="label" for=""</label>
<div class="control">
<select name="super_attribute" id="attribute" class="super-attribute-select">
<option value="1">1</option>
</select>
</div>
<label class="label" for="qty"><span>Qty</span></label>
<div class="control">
<input type="number" name="qty" id="qty1" maxlength="12" value="1" title="Qty" class="input-text qty" data-validate="">
</div>
</div>
<div class="actions">
<button type="submit"
title=""
class="action primary tocart"
id="act">
<span>Add new item</span>
</button>
</div>
jQuery(function(){
var len = 0;
jQuery('#act').click(function(){
jQuery("#test").clone(true, true).insertAfter("div#test:last");
$('div#test:last').attr('id', 'test'+len);
//set name for select box
$('div#test'+len+' select').attr('name', 'super_attribute'+len);
len++;
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="test" class="test">
<input type="hidden" name="product" value="<?php /* #escapeNotVerified */ echo $_product->getId() ?>" />
<input type="hidden" name="selected_configurable_option" value="" />
<input type="hidden" name="related_product" id="related-products-field" value="" />
<label class="label" for=""</label>
<div class="control">
<select name="super_attribute" id="attribute" class="super-attribute-select">
<option value="1">1</option>
</select>
</div>
<label class="label" for="qty"><span>Qty</span></label>
<div class="control">
<input type="number" name="qty" id="qty1" maxlength="12" value="1" title="Qty" class="input-text qty" data-validate="">
</div>
</div>
<div class="actions">
<button type="submit"
title=""
class="action primary tocart"
id="act">
<span>Add new item</span>
</button>
</div>
Generate some unique random numbers and append it to your id using .attr() method
jQuery(function() {
jQuery('#act').click(function() {
var randomnumber = Math.ceil(Math.random() * 100)
var el = jQuery("#test").clone(true, true).insertAfter("div#test:last").attr('id', 'test' + randomnumber);
console.log('id = ' + el.attr('id'));
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="test" class="test">
<input type="hidden" name="product" value="<?php /* #escapeNotVerified */ echo $_product->getId() ?>" />
<input type="hidden" name="selected_configurable_option" value="" />
<input type="hidden" name="related_product" id="related-products-field" value="" />
<label class="label" for=""</label>
<div class="control">
<select name="super_attribute" id="attribute" class="super-attribute-select">
<option value="1">1</option>
</select>
</div>
<label class="label" for="qty"><span>Qty</span></label>
<div class="control">
<input type="number" name="qty" id="qty1" maxlength="12" value="1" title="Qty" class="input-text qty" data-validate="">
</div>
</div>
<div class="actions">
<button type="submit"
title=""
class="action primary tocart"
id="act">
<span>Add new item</span>
</button>
</div>
If you want to change just the new elements, apply map (from the top of my head, untested);
jQuery(".test").clone(true, true).map(function(el, index) {
return jQuery(el).attr("id", "test-" + index);
}).insertAfter("div.test:last");
Also, selecting multiple elements by ID (#test), will probably not work, and it's not allowed according to the spec to have multiple elements on a single page with the same ID. So that's why I used a class selector in my code above.
I have a situation where I want to auto submit form in cakephp ctp file. Can anyone please help me? I know there are number of same or similar question have asked before this. It tried everything, but it doesn't work. Please have a look on my code:
SCRIPT PART:
<script>
window.onload = function() {
alert("reached here");
document.frmTransaction.submit();
}
</script>
HTML PART:
<form method="post" action="https://secure.ebs.in/pg/ma/sale/pay" name="frmTransaction" id="frmTransaction" onSubmit="return validate()" onLoad="javascript:autoSubmit();">
<input name="account_id" type="hidden" value="<?echo $_POST['account_id'] ?>" />
<input name="return_url" type="hidden" size="60" value="<?echo $_POST['return_url'] ?>" />
<input name="mode" type="hidden" size="60" value="<? echo $_POST['mode']?>" />
<table style="width:50%">
<tr>
<td>Reference: </td><td><input name="reference_no" type="text" value="<? echo $_POST['data']['reference_no'] ?>" readonly/></td>
</tr>
<tr>
<td>Amount: </td><td><input name="amount" type="text" value="<? echo $_POST['data']['amount'] ?>" readonly/>Rs.</td>
</tr>
</table>
<input name="description" type="hidden" value="<? echo $_POST['description'] ?>" />
<input name="name" type="hidden" value="<? echo $_POST['name'] ?>" />
<input name="email" type="hidden" value="<? echo $_POST['email'] ?>" />
<input name="phone" type="hidden" value="<? echo $_POST['phone'] ?>" />
<input name="address" type="hidden" value="<? echo $_POST['address'] ?>" />
<input name="country" type="hidden" value="IND" />
<input name="postal_code" type="hidden" value="<? echo $_POST['postal'] ?>" />
<input name="state" type="hidden" value="<? echo $_POST['state'] ?>" />
<input name="city" type="hidden" value="<? echo $_POST['city'] ?>" />
<input name="secure_hash" type="hidden" size="60" value="<? echo $secure_hash;?>" />
<br/><br/><br/><input name="submit" value="Submit" type="submit" id="submit" style="background:#ff6600;color:#fff;height:40px;width:150px;font-family:Calibri;font-size: 22px;"/>
</form>
You have to check form definition again.
Remove onload event statement.
<form method="post" action="https://secure.ebs.in/pg/ma/sale/pay" name="frmTransaction" id="frmTransaction" onSubmit="return validate()">
I have a javascript function named formApprove() and am calling that function within html onclick on a button. For some reason the javascript function is not being recognized because firebug tells me that the forApprove is not a function. Below is the code in the head:
<script type="text/javascript">
function formApprove() {
var TheTextBox = document.getElementById("formApprove");
TheTextBox.value = 'true';
alert("hellp");
return true;
}
</script>
Below is the code in the body:
<input type="submit" name="approve" value="Approve Membership" onclick="formApprove()" />
Any help on this would be greatly appreciated.
Full Code:
<head>
<script type="text/javascript">
function nextPrevious(txtElement, btnElement) {
switch(btnElement.name) {
case 'increase':
var numrows = document.getElementById("numOfRows");
if (txtElement.value < Number(numrows.value)) {
txtElement.value++;
} else {
alert('You are alread at the end of the members');
return false;
}
break;
case 'decrease':
if(txtElement.value > 1) {
txtElement.value--;
} else {
alert('You are alread at the begining of the members');
return false;
}
break;
case 'goto':
alert(txtElement.value);
break;
default:
}
return true;
}
function approve() {
var TheTextBox = document.getElementById("formApprove");
TheTextBox.value = 'true';
alert("hellp");
return true;
}
function formChange() {
var TheTextBox = document.getElementById("formSubmit");
TheTextBox.value = 'true';
return true;
}
function deleteRecord() {
var answer = confirm ("Are you sure you want to delete record?");
if (answer) {
var TheTextBox = document.getElementById("formDelete");
TheTextBox.value = 'true';
return true;
} else {return false;}
}
</script>
</head>
<body>
<form name="members_view" method="POST" action="viewpending.php">
<br />
<div id="buttons">
<input type="submit" name="update" value="Update Record" onclick="formChange(this.form.elements['formSubmit'].value)" /> -
<input type="submit" name="decrease" value="Previous" onclick="nextPrevious(this.form.elements['record'], this)" /> -
<input type="submit" name="increase" value="Next" onclick="nextPrevious(this.form.elements['record'], this)" /> -
<input type="submit" name="delete" value="Delete Record" onclick="deleteRecord(this.form.elements['formSubmit'].value)" /> -
<input type="submit" name="approve" value="Approve Membership" onclick="approve()" />
</div>
</div>
<div id="leftcase">
<div class="label">First Name:</div><div class="input"><input size="40" type="text" name="FNAME" value="<?php echo $row['FNAME']; ?>" /></div>
<div class="label">Middle Name:</div><div class="input"><input size="40" type="text" name="MNAME" value="<?php echo $row['MNAME']; ?>" /></div>
<div class="label">Last Name:</div><div class="input"><input size="40" type="text" name="LNAME" value="<?php echo $row['LNAME']; ?>" /></div>
<div class="label">Full Name:</div><div class="input"><input size="40" type="text" name="FULL_NAME" value="<?php echo $row['FNAME'].' '.$row['MNAME'].' '.$row['LNAME']; ?>" /></div>
<div class="label">Nick Name:</div><div class="input"><input size="40" type="text" name="NNAME" value="<?php echo $row['NNAME']; ?>" /></div>
<div class="label">Spouse/Partner Name:</div><div class="input"><input size="40" type="text" name="H_COUNTRY" value="<?php echo $row['H_COUNTRY']; ?>" /></div>
<div class="label">Anniversary Date:</div><div class="input"><input size="40" type="text" name="B_ZIP" value="<?php echo $row['B_ZIP']; ?>" /></div>
<div class="label">Primary Email:</div><div class="input"><input size="40" type="text" name="EMAIL" value="<?php echo $row['EMAIL']; ?>" /></div>
<div class="label">Second Email:</div><div class="input"><input size="40" type="text" name="B_CITY" value="<?php echo $row['B_CITY']; ?>" /></div>
<div class="label">Home Street:</div><div class="input"><input size="40" type="text" name="H_STREET" value="<?php echo $row['H_STREET']; ?>" /></div>
<div class="label">Home City:</div><div class="input"><input size="40" type="text" name="H_CITY" value="<?php echo $row['H_CITY']; ?>" /></div>
<div class="label">Home State:</div><div class="input"><input size="40" type="text" name="H_STATE" value="<?php echo $row['H_STATE']; ?>" /></div>
<div class="label">Home Zip:</div><div class="input"><input size="40" type="text" name="H_ZIP" value="<?php echo $row['H_ZIP']; ?>" /></div>
<div class="label">Home Phone:</div><div class="input"><input size="40" type="text" name="H_PHONE" value="<?php echo $row['H_PHONE']; ?>" /></div>
<div class="label">Cell:</div><div class="input"><input size="40" type="text" name="H_CELL" value="<?php echo $row['H_CELL']; ?>" /></div>
<div class="label">Birth Date:</div><div class="input"><input size="40" type="text" name="H_WEB" value="<?php echo $row['H_WEB']; ?>" /></div>
<div class="label">Membership Exp:</div><div class="input"><input size="40" type="text" size="40" name="MEMBER_INFO" value="<?php echo $row['MEMBER_INFO']; ?>" /></div>
<div class="label">Retired Mil Info:</div><div class="input"><input size="40" type="text" name="B_STATE" value="<?php echo $row['B_STATE']; ?>" /></div>
<div class="label">1st tour from:</div><div class="input"><input size="40" type="text" name="B_COUNTRY" value="<?php echo $row['B_COUNTRY']; ?>" /></div>
<div class="label">1st tour Rank/Rate:</div><div class="input"><input size="40" type="text" name="B_WEB" value="<?php echo $row['B_WEB']; ?>" /></div>
<div class="label">1st tour cruise Book:</div><div class="input"><input size="40" type="text" name="B_PHONE" value="<?php echo $row['B_PHONE']; ?>" /></div>
<div class="label">2nd tour from:</div><div class="input"><input size="40" type="text" name="B_FAX" value="<?php echo $row['B_FAX']; ?>" /></div>
<div class="label">2nd tour Rank/Rate:</div><div class="input"><input size="40" type="text" name="PAGER" value="<?php echo $row['PAGER']; ?>" /></div>
<div class="label">2nd tour cruise Book:</div><div class="input"><input size="40" type="text" name="B_COMPANY" value="<?php echo $row['B_COMPANY']; ?>" /></div>
<div class="label">3rd tour from:</div><div class="input"><input size="40" type="text" name="B_TITLE" value="<?php echo $row['B_TITLE']; ?>" /></div>
<div class="label">3rd tour Rank/Rate:</div><div class="input"><input size="40" type="text" name="B_DEPT" value="<?php echo $row['B_DEPT']; ?>" /></div>
<div class="label">3rd tour cruise book:</div><div class="input"><input size="40" type="text" name="OFFICE_LOC" value="<?php echo $row['OFFICE_LOC']; ?>" /></div>
</div>
<div id="rightcase">
<div class="label">Biography:</div><div class="input"><textarea rows="35" cols="80" name="NOTES" /><?php echo $row['NOTES']; ?></textarea></div>
<input type="hidden" id="record" name="record" value="<?php echo $_POST['record']; ?>"/>
<input type="hidden" id="formSubmit" name="formSubmit" value="<?php echo $_POST['formSubmit']; ?>" />
<input type="hidden" id="formApprove" name="formApprove" value="<?php echo $_POST['formApprove']; ?>" />
<input type="hidden" id="formDelete" name="formDelete" value="<?php echo $_POST['formDelete']; ?>" />
<input type="hidden" id="numOfRows" name="numOfRows" value="<?php echo $num_rows; ?>" />
<input type="hidden" id="ID" name="ID" value="<?php echo $_POST['ID']; ?>"/>
</div>
<div id="buttons">
<input type="submit" name="update" value="Update Record" onclick="formChange(this.form.elements['formSubmit'].value)" > - <input type="submit" name="decrease" value="Previous" onclick="nextPrevious(this.form.elements['record'], this)" > - <input type="submit" name="increase" value="Next" onclick="nextPrevious(this.form.elements['record'], this)" > - <input type="submit" name="delete" value="Delete Record" onclick="deleteRecord(this.form.elements['formSubmit'].value)" >
</form>
</body>
You probably have a name clash with the function and the name of the element.
Either rename the function or rename the textbox.