home.php
<?php print"$i->sm_jo<br>$i->sm_custo_name"; ?>
ppc-mngt_transfer.php
<script type="text/javascript">
function refreshAndClose() {
window.close();
window.opener.location.reload(true);
}
</script>
<body onbeforeunload="refreshAndClose();">
<form name='mainform' method='post' action='do.php?ppc/workload'>
<?php
print "<h1>COPY TO WORKLOAD</h1>";
print "<table class='clean_form'>";
print "<tr><td>J.O. Number</td><td><input name='ppc_jo' value='$i->sm_jo' style='width:250'></td></tr>";
print "<tr><td>Customer Name</td><td><input name='ppc_custo_name' value='$i->sm_custo_name' style='width:250'></td></tr>";
print "<tr><td>Description</td><td><input name='ppc_subject' value='$i->sm_subject' style='width:250'></td></tr>";
print "<tr><td>Date Start</td><td><input name='ppc_dpdate' value='$i->sm_dpdate' style='width:250'></td></tr>";
print "<tr><td>Duration</td><td><input name='ppc_proj_duration' value='$i->sm_proj_duration' style='width:250'></td></tr>";
print "<input type='hidden' name='ppc_m_id' value='$id'>";
print "</table>";
print "<tr><input type='checkbox' name='ppc_mark' value='ok' checked/></tr>";
?>
<input type="submit" value="submit">
</form>
</body>
I think my code does this > REFRESH then Close .... What I need is Close after clicking the submit button in the pop-up then Refresh the parent page. Please help me I have a poor knowledge in Javascript.
<form name='mainform' method='post' action='do.php?ppc/workload' onsubmit="refreshAndClose();">
function refreshAndClose() {
window.opener.location.reload(true);
window.close();
}
Just make sure the form is really submitted, if not, we need to tweak it a bit.
I would actually to the window.close() in the do.php file. So u can also handle submission errors, if they occur.
Related
I have a fieldset in the html page.I need the field set to be invisible during a specific radio button click.
$cat is the radiobutton name,Dessert is the value.This radio button is inside the field set
The following code does not work.
How to do this through php code.I don't need to be done with javascript or jquery.
Here is the Code :
<?
if((!empty($cat) && $cat==="Dessert"))
{
echo "<fieldset id='typeradio' hidden='hidden'>";
echo"success";
} >?
How can i do this ?
You can disable it if you don't want it to work
<fieldset id="typeradio" disabled>
or hide it using CSS
<fieldset id="typeradio" style="display: none;">
Try This
It will only work if you post back your page and set the $cat property there otherwise you will have to do it via Jquery or JavaScript or ajax request. By post back i mean full page reload and server will do all checks and apache server will generate Html for this if condition
<?
if((!empty($cat) && $cat==="Dessert"))
{
echo "<fieldset id='typeradio' style='display:none'>";
echo"success";
} >?
//this example.php
<?
if(isset($_POST['opt'])){
$cat=$_POST['opt'];
if($cat==="Dessert")
{
echo "<form name="frm" action='example.php' method="post"><fieldset id='typeradio' hidden='hidden'><input type='radio' name='opt' value="Dessert" onclick="this.form.submit();"></fieldset></form>";
echo"success";
}
}
else
{
echo "<form name="frm" action='example.php' method="post"><fieldset id='typeradio' ><input type='radio' name='opt' value="Dessert" onclick="this.form.submit();"></fieldset></form>";
}
>?
//there was some quotes mistakes in previous code try this
<?php
if(isset($_POST['opt'])){
$cat=$_POST['opt'];
if($cat==="Dessert")
{
echo "<form name='frm' action='example.php' method='post'><fieldset id='typeradio' hidden='hidden'><input type='radio' name='opt' value='Dessert' onclick='this.form.submit();'></fieldset></form>";
echo"success";
}
}
else
{
echo "<form name='frm' action='' method='post'><fieldset id='typeradio' ><input type='radio' name='opt' value='Dessert' onclick='this.form.submit();'></fieldset></form>";
}
?>
I have a form that contains two button
but when I press on one of them nothing happen
and I can't find the problem can you help me please !!
here my php code :
<?php
session_start();
include 'connection.php';
// in this section, I retrieve data from database and display them on table
// if agree button pressed do the following
if (isset($_POST['agree']))
{
$que="update project set status='submitted' ,projectstatus=1 where projectid=$id ";
$result3=mysql_query($que);
if ($result3)
{
echo(" <script>
alert('The project has been approved');
</script>");
header( "Location:unsubmited.php" );
}
else
{
echo "an error occur can't agree on this project";
}
}
?>
and this is the form :
<form action='' method='post'>
<input type='button' name='disagree' value='disagree ' class='styled-button-11'>
<input type='button' name='agree' value='agree' class='styled-button-11'>
</form>
thanx ^^
Change your code for this, as it says andrewsi:
<form action='' method='post'>
<input type='submit' name='disagree' value='disagree ' class='styled-button-11'>
<input type='submit' name='agree' value='agree' class='styled-button-11'>
</form>
I believe this is as simple as, filling in the action='' to the page to post back to and setting the type='submit' as andrewsi suggested.
and thanks for the great help your community provides.
Here is a question regarding Paypal. The code below creates a buy-now non-hosted button. I would like to be able to do run my geoTestArray.php code, currently simply included, as the user presses the Buy Now button, and not when the button is displayed on the page.
Is this possible at all?
Thanks in advance,
Joe
<?php
include ('geoTestArray.php');
echo "<form action=\"https://www.paypal.com/cgi-bin/webscr\" method=\"post\">
<input type=\"hidden\" name=\"business\" value=\"shop#mysite.com\">
<input type=\"hidden\" name=\"cmd\" value=\"$cmd\">
<input type=\"hidden\" name=\"amount\" value=\"$price\">
<input type=\"hidden\" name=\"shipping\" value=\"$shipping\">
<input type=\"hidden\" name=\"currency_code\" value=\"$currency\">
<input type=\"hidden\" name=\"shipto\" value=\"$shipto\">
<input type=\"hidden\" name=\"item_name\" value=\"$title\">";
if ($cmd == 'cart') {
echo "<input type=\"hidden\" name=\"add\" value=\"1\">";
}
include('./quantities2.php');
echo "<input type=\"hidden\" name=\"lc\" value=\"US\">
<input class=\"submit\" type=\"image\" src=\"$button\" border=\"0\" name=\"submit\" alt=\"$altaction\">
<img alt=\"\" border=\"0\" src=\"https://www.paypal.com/en_US/i/scr/pixel.gif\" width=\"1\" height=\"1\">
</form>";
?>
You can display only a form with one input, for example item_id.
After submitting this form you search for item details, execute your geoTestArray.php in backend and after that you can redirect your users to paypal using header("location: $query");
here's how I would do:
<?php
if( isset($_POST['do_action']) && $_POST['do_action'] != "" ) {
//check for non-empty item_id field
//run your geoTestArray.php script
//get item details from database and build your paypal query
$query = "https://www.paypal.com/cgi-bin/webscr&cmd=_xclick"; // add rest of paypal request fields separated by &
header( "Location: $query" );
}
?>
<form action='' method='post'>
<input type='hidden' name='item_id' value'your_item_id'>
<input type='submit' name='do_action' value='Buy'>
<form>
Hope I helped you! :d
Thanks everyone for comments and solution options. I have eventually chosen to modify an onSubmit javascript I had on my page, by adding:
function InterceptForm(formObj) {
var newshipto = httpGet('geoTestArray.php');
formObj.shipto.value = newshipto;
}
The above code makes use of the httpGet() function posted in this other stackoverflow post:
HTTP GET request in JavaScript?
To complete the puzzle:
The code below is in the html in my page
<script language="javascript">
// During onLoad, loop through all forms and for each form object do something
function InterceptForm(formobj) {
formobj.onsubmit = function ff() {
interceptform(formobj);
};
}
</script>
The code below gathers all forms on the page and runs the above javascript on each (NOTE: you may want to name your forms so that you only run the script on the relevant forms and not on all forms):
<script language="javascript">
function GetForms() {
var formsCollection = document.getElementsByTagName("form");
for(var i=0;i<formsCollection.length;i++)
{
if (formsCollection[i].name != "seecart")
{
InterceptForm(formsCollection[i]);
}
}
return true;
}
</script>
The code below is the onLoad function:
<script language="javascript">
function onLoadFunction () {
GetForms();
return true;
}
</script>
Cheers,
Joe
<?php
require "../db/dbconfig.php";
$gal=mysql_query("select * from gallery");
$numrows=mysql_num_rows($gal);
if($numrows>=1)
{
echo "<form action='delete.php' method='post' name='f2' id='f2'>";
echo '<table id="rqst" style="display:block;" border="0" cellpadding="12" cellspacing="3" width="500px">';
echo "<tr><th>Tick to select</th><th>Images in Gallery</th></tr>";
while($row=mysql_fetch_array($gal)
{
$imgfile=$row['ImgName'];
$Image="<img src=gallery/".$imgfile." width='230px' height='150px'/>";
$img_name=$imgfile;
echo "<tr>";
echo "<td><input type='checkbox' name='imgs[]' value='$img_name'></td><td>".$Image."</td>";
echo "</tr>";
}
echo "<tr>";
echo "<td colspan='3' align='right'>";
echo "<input type='submit' value='Delete' name='del'></td>";
echo "</tr>";
echo "</table>";
echo "</form>";
?>
This is my code....This will display images from gallery and checkboxes associated with them. When I click delete button with unchecked checkboxes an alert should come like this "Please check at least one checkbox"..How to do that??
My next problem is,,when I click delete button after checked checkbox, alert should come like this=" Do you want to delete?? "...If clicked Ok,the image must be deleted else do nothing...Please help ...Thanks in advance....
check this below link for validation using jquery:
http://jsfiddle.net/susheel61/U3Unk/2/
<form id="form">
First name: <input type="checkbox" name="firstname" class="check"><br>
<button>test</button>
</form>
$("button").on("click",function(e){
var status = $(".check").is(":checked");
e.preventDefault();
if(!status){
alert("this is not checked");
}
});
Yes, you can do it by javascript or jquery to validate whether your atleast one checkbox is select or not. So, for that you need to give a common class for all checkbox as example
<input type="checkbox" name="firstname" class="addchk">
Now in your submit button call a javascript function which validate the matter.
<input type='button' value='Delete' name='del' onclick='delete_checked()' />
Now write a function to validate whether any checkbox is selected.
function delete_checked()
{
var status = $(".addchk").is(":checked");
e.preventDefault();
if(!status){
alert("this is not checked");
}
else
{
// SUbmit yout form
}
}
I want to refresh the same page and display the entered value in text box on the same page after clicking the link or button.
I have the following code:
<?php
echo '<h3>Fee Payment</h3>';
echo "<form id='myFormId' name='myFormName'>";
echo " <input type='text' name='myTextField'>";
echo "<a href='{$_SERVER['PHP_SELF']}?student_no=myTextField'> Search Student</a>";
if (!(isset($_GET[student_no])))
{
echo "No Student is available.";
}
else
{
$student_no = $_GET['student_no'];
echo "Student NO:".$studen_no;
}
?>
Please guide me how to achieve the goal and whats the error my code.
<?php
echo '<h3>Fee Payment</h3>';
if(isset($_POST['myTextField']))
$value=$_POST['myTextField'];
else
$value='';
echo "<form id='myFormId' name='myFormName' method='post'>";
echo " <input type='text' name='myTextField' value='$value'>";
echo "<a href='{$_SERVER['PHP_SELF']}?student_no=myTextField'> Search Student</a>";
You also need a submit button in the form, and a form close tag.
What you want is AJAX. I am just providing you an example of how you can proceed by using jQuery, but you can use any other library / framework or any other way also. You can check this article also for more usability details.
In the main page:-
<?php
echo '<h3>Fee Payment</h3>';
echo "<form id='myFormId' name='myFormName'>";
echo "<input type='text' name='myTextField' id='myTextField' />";
echo 'Search Student';
echo "</form>";
?>
<script type="text/javascript">
$('#inline_submit_a').click(function(evt){
$.ajax({
type: "GET",
url: "handler.php",
data: {text:$('#myTextField').val()}
});
evt.preventDefault();
return false;
});
</script>
In the "handler.php" page:-
<?php
if (!(isset($_GET[student_no])))
{
echo "No Student is available.";
}
else
{
$student_no = $_GET['student_no'];
echo "Student NO:".$student_no;
}
?>
You can write all the logic related to the database in the "handler.php" page.
Hope it helps.
You're using a link to submit the form, but you should be using a submit button.
<input type="submit" value="Search student" />
You didn't close the <form> tag.
You're using $_GET[student_no] which will make PHP look for a definition of student_no. Since it's a string, express it as one. $_GET['student_no'] is better.
Why can't you submit the form? Do you want to have a link for searching instead of a button?
You could configure the link to submit the form via javascript and change the form action to GET like this:
<?php
echo '<h3>Fee Payment</h3>';
echo "<form id='myFormId' name='myFormName'
action='{$_SERVER['PHP_SELF']}' method='GET'>";
echo " <input type='text' name='student_no'>";
echo "<a href='javscript:document.forms.myFormName.submit()'>
Search Student</a>";
...