I have a table and use the following to create a button inside one of the cells:
print("<td> <input type=\"submit\" name=\"toedit\" value=\"Submit\" >
<form action=\"Manage_Customer_Information_refined_list.php\" method=\"post\">
<input type=\"hidden\" value=\"Submit\" name =\"submit_button\" >
</form>
</td>");
When i go to call upon the button (press it) using
if(print_r($_POST["\"submit_button\""]))
{
print "button pressed";
}
It says
undefined index "submit_button"
Please Help :/
try this
print("<td>
<form action=\"Manage_Customer_Information_refined_list.php\" method=\"post\">
<input type=\"hidden\" value=\"Submit\" name =\"submit_button\" >
<input type=\"submit\" name=\"toedit\" value=\"Submit\" >
</form>
</td>");
and if you want to submit on same page then remove Manage_Customer_Information_refined_list.php form form.
Change
<input type=\"hidden\" value=\"Submit\" name =\"submit_button\" >
to
<input type=\"submit\" value=\"Submit\" name =\"submit_button\" >
Remove
<input type=\"submit\" name=\"toedit\" value=\"Submit\" >
Change your condition to this
if(isset($_POST["submit_button"]))
{
print "button pressed";
}
The code you write <input type=\"hidden\" value=\"Submit\" name =\"submit_button\" > will be evaluated to ... name="submit_button" which means you should access this input value from the server side using $_POST["submit_button"].
The way you did write $_POST["\"submit_button\""] expect the input field to be written as <input type=\"hidden\" value=\"Submit\" name =\"\"submit_button\"\" > and i don't think that this is a valid syntax, also you should put the submit button inside the form not outside of it.
Related
Advance thanks for your help. I am not understanding why it is not working. I am a beginner and hence I am not finding the problem. Please anyone help me...
echo "<form method='POST'><br>
<p>Would you Like to create your Account with Details Information<b>?
</b>
<br><br>
<input type='button' id='yes' name='yes' value='Yes'/>
<input type='button' id='no' name='no' value='No'/></p>
</form>";
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (isset($_POST['yes'])) {
echo "Yes Clicked";
} else if (isset($_POST['no'])) {
echo "<br><br><p> You have successfully Registered!!!</p>";
}
}
Replace button with submit
<input type='submit' id='yes' name='yes' value='Yes'/>
<input type='submit' id='no' name='no' value='No'/></p>
try this code :
<?php
echo "<form method='POST' action='index.php'><br>
<p>Would you Like to create your Account with Details Information<b>?
</b>
<br><br>
<input type='submit' id='yes' name='yes' value='yes'/></p>
<input type='submit' id='no' name='no' value='No'/></p>
</form>";
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (isset($_POST['yes'])) {
echo "<br><br><p> Yes clicked!!!</p>";
} else if (isset($_POST['no'])) {
echo "<br><br><p> You have successfully Registered!!!</p>";
}
}
?>
form are trigged with input type submit , so if you want to get value of two input , they must be a submit input instead of button . in this cas , you have two input type submit , theey should be type submit with different name .that's all
You have to change your button's type attributes to submit instead of button, or else they won't actually submit the form.
<input type='submit' id='yes' name='yes' value='Yes'/>
I'm making a Quiz. And with each question I'm showing the possible answers( "True" or "False") with a While loop in PHP:
echo "<form method='post' action='quizCheck.php'>";
while(x=0;x<=10; x++){
echo "<div class='buttons'>
<label>True
<input type='radio' name='answer' value='true' />
</label>
<label>False
<input type='radio' name='answer' value='false' />
</label>
</div>";
}
echo "</form>";
Let's say there are 10 questions and I select "True" on 6 questions.
What code do I have to put in quizCheck.php so it can count the number of "True" answers and store it in a variable?
You will need to do two things, first you need a submit button in the form:
<button type="submit" value="Submit">Submit</button>
Then you will also need the names of the radio inputs to be unique so in the while loop (which you really should just change to a for loop) do:
for(x=0;x<=10; x++){
echo "<div class='buttons'>
<label>True
<input type='radio' name='answer{$x}' value='true' />
</label>
<label>False
<input type='radio' name='answer{$x}' value='false' />
</label>
</div>";
}
When the form is submitted, then in quizCheck.php you just check $_POST[answer0] through $_POST[answer9] to see which are true and increment a counter.
If you want the answers in a single array then do this:
for(x=0;x<=10; x++){
echo "<div class='buttons'>
<label>True
<input type='radio' name='answers[$x]' value='true' />
</label>
<label>False
<input type='radio' name='answers[$x]' value='false' />
</label>
</div>";
}
When this form is submitted, then in quizCheck.php you just get something like $answers = $_POST[answers] and then go through answers[0] to answers[9] for example
I am trying to echo out this following input submit button Using php.. .
<input type='submit' value='submit' onClick='parent.location='order_summary.php'>
I wrote the following code before but its not working :(
Can anyone please help me out with this? Thanks!
echo "<input type='submit' value='submit' onClick='parent.location="."'order_summary.php'".">";
You need to learn about escaping quotes so you don't write broken HTML:
echo "<input type='submit' value='submit' onClick='parent.location=\"order_summary.php\"'>";
or alternatively (since valid HTML uses double quotes):
echo '<input type="submit" value="submit" onClick="parent.location = \'order_summary.php\'">';
I am having a bit of troubles submitting my form with jQuery..
I got this:
<div class='widget-body'>
<div class='center' id='formHolder' style='display:none'>
<div id='amountDiv'>$<span id='amountSpan'></span></div>
<div class='pagination pagination-centered margin-none' style='font-size:15px;'>
<ul>
<li><a href='javascript:void(0)' id='dec'>-</a></li>
<li class='active'><a href='javascript:void(0)' class='addfunds'>Add Funds</a></li>
<li><a href='javascript:void(0)' id='inc'>+</a></li>
</ul>
</div><!--//Pagination-->";
$contents .= "
<form action=\"https://www.paypal.com/cgi-bin/webscr\" method=\"post\" id=\"ppform\">
<input type=\"hidden\" name=\"cmd\" value=\"_xclick\" />
<input type=\"hidden\" name=\"business\" value=\"{$set['pp_paymentemail']}\" />
<input type=\"hidden\" name=\"quantity\" value=\"1\" />
<input type=\"hidden\" name=\"item_name\" value=\"{$set['rbalanceadd_paymenttext']}\" />
<input type=\"hidden\" name=\"amount\" class='a' value=\"\" />
<input type=\"hidden\" name=\"item_number\" value=\"{$ir['username']}\" />
<input type=\"hidden\" name=\"no_shipping\" value=\"1\" />
<input type=\"hidden\" name=\"return\" value=\"$return\" />
<input type=\"hidden\" name=\"currency_code\" value=\"{$set['currency_type']}\" /></form>
<form method=\"post\" action=\"https://secure.payza.com/checkout\" id='pzform' />
<input type=\"hidden\" name=\"ap_purchasetype\" value=\"service\" />
<input type=\"hidden\" name=\"ap_merchant\" value=\"{$set['ap_paymentemail']}\" />
<input type=\"hidden\" name=\"ap_itemname\" value=\"{$set['rbalanceadd_paymenttext']}\" />
<input type=\"hidden\" name=\"ap_currency\" value=\"{$set['currency_type']}\" />
<input type=\"hidden\" name=\"ap_returnurl\" value=\"{$myi}\" />
<input type=\"hidden\" name=\"ap_quantity\" value=\"1\" />
<input type=\"hidden\" name=\"ap_amount\" class='a' value=\"\" />
<input type=\"hidden\" name=\"ap_description\" value=\"{$ir['username']}\" />
</form>
";
$contents.="
</div><!--//formHolder-->
<div id='btHolder'>
<div class='center'>
<img src='themes/steel/theme/images/icons/paypal.png' style='margin-left:10px;margin-right:10px;' id='paypalBt'>
<img src='themes/steel/theme/images/icons/payza.png' id='payzaBt'>
</div><!--//Center-->
<br />
</div><!--//btHolder-->
</div><!--//Widget Body-->
So, first off all the user is choosing his/her payment method. That is done by either choosing #payzaBt or #paypalBt
After that, the user must specify how much money he/she wishes to add.
That is done with #inc or #dec (This will add the amount to the amount input field of both the PayPal and Payza form.
My jQuery looks like this:
$(document).ready(function() {
$('#paypalBt').click(function() {
$('.addfunds').attr('id','addfundspp');
$('#btHolder').hide();
$('#formHolder').show();
});
$('#payzaBt').click(function() {
$('.addfunds').attr('id','addfundspz');
$('#btHolder').hide();
$('#formHolder').show();
});
$('#addfundspz').click(function() {
$('#pzform').submit();
});
$('#addfundspp').click(function() {
$('#ppform').submit();
});
$('#amountSpan').text('5');
$('.a').val('5');
$('#inc').click(function(){
$('#amountSpan').text( Math.min(100, Number($('#amountSpan').text()) + 5) )
$('.a').val( Math.min(100, Number($('.a').val()) + 5) )
});
$('#dec').click(function(){
$('#amountSpan').text( Math.max(5, Number($('#amountSpan').text()) - 5) )
$('.a').val( Math.max(5, Number($('.a').val()) - 5) )
});
});
Now all of this works fine. The problem is when the user must submit the PayPal or the Payza form. As you can see in the above jQuery code I am first adding an ID attribute to the "Add Funds" button; when that button is clicked, I am using the jQuery submit form function. But this doesn't work. No form is submitted.
What is wrong?
Thanks in advance.
That is because #addfundspz (and #addfundspp) doesn't exist when document is ready
You can use event delegation
$(document).on('click','#addfundspz',function() {
$('#pzform').submit();
});
http://learn.jquery.com/events/event-delegation/
how to pass a php variable to dynamicaly generated div's onclick event?
here is my code
while($rowset = mysql_fetch_array($result))
{
$idTT1++;
$editTT='b'.$idTT1;
$hidTextTT='t'.$idTT1; $hidSubIdTT='s'.$idTT1;
echo "<tr><td>".$rowset[1]." ".$rowset[2]."</td><td> </td>
<td class='table_label'>
<div id='".$idTT1."' onclick='editView($idTT1,$editTT)' >".$rowset[3]."</div>";
echo "<div id='".$editTT."' style='display:none;'>
<input id='".$hidSubIdTT."' name='box1' type='hidden' value='".$row['dDegreeName']."'>
<input id='".$hidTextTT."' name='box2' type='text' value='' />
<input type='submit' value='Update' name='submit'
onclick='updateSubject($hidSubIdTT,$hidTextTT)'/>
<input type='button' value='Cancel' name='Cancel' onclick='setEditView($idTT1,$editTT)'/>
</div></td></tr>";
}
i want to pass 2 variables $idTT1 and $editTT. im getting the value of $editTT1 in javascript but i cant get value of $editTT value in editView() javascript function.
That is probably because you are not quoting the IDs. Try
setEditView(\"$idTT1\",\"$editTT\")
in the line before last.
You need to put it between quotes. Something like this should work:
"<input type='button' value='Cancel' name='Cancel' onclick='setEditView(\"$idTT1\",\"$editTT\")'/>"