It is possible to create a pdf file after a PHP form has been submited?
I need to print an order details after a php form is submited.
At this time i have a small jquery script that allows to print page that it prints only html content the php variables not.
$(document).ready(function() {
$(".btnPrint").printPage();
});
Any advice much appreciated.
Related
I have a single page of HTML that includes PHP code.
I am using the PHP to send data from a form to the same page using $_SERVER['PHP_SELF'] as the form action.
There is an isset($_POST... condition in the PHP that detects if the page has loaded with data via POST. If this is true, the PHP compares the value sent to a set maximum value.
If the data is less than the maximum value, a table is displayed.
If the data exceeds the maximum value, I would like to display an error message using jQuery: $('.error_box').append("Error");
The error message is not displaying. I think this is because the PHP is trying to make changes to .error_box before it has loaded.
How can I make sure that the error display function is available, given that I am validating the form data via PHP as soon as the page loads?
You don't have to use javascript or jQuery to add content to '.error_box'
You should add it with PHP directly.
EDIT:
You must know that you can't directly execute javascript via PHP.
Here is how your page is created then rendered (this is simpler than reality) :
Your server receive the request to display a page
The PHP code is executed and output an HTML (+CSS +JS) page
The output is send back to the client who ask for page
The client browser parse the HTML and render it using css rules you specified
The javascript is executed
Wrap it in a document ready function, like so:
$(document).ready(function() {
$('.error_box').append("Error");
});
Edit:
AMDG is probably right also...
I have a button when user click on that button it appends a dropdown list to the HTML and I have used PHP to retrieve data from database in fill the dropdown list, while i try this code it is not working for me! any idea?
$(".pageSheet").on("click", ".bt2", function () {
$(this).closest(".pageIn").append("<p>Image: <select name='image'>
<?php include'scripts/addImage.php'; addImg(); ?></select><br><button class='deleteCon'>Delete</button></p>"); i++;});
You cannot append <?php // code here ?> to an already rendered webpage using JavaScript and expect PHP to parse it. PHP parses the page while it is being handled by the webserver attending to the request. If you want JavaScript (client-side) to interact with something PHP generates from a Database (server-side), you need to look into AJAX.
I'm looking for some general advice on the code design of a form which has to generate an image when submitted. I'm new to this, and the data communication from the form to the image generator has me stumped. Any advice appreciated (I've got lots of C experience, a bit of JavaScript, no php).
Problem: a user has to fill in a form (in Joomla). The user sets a number of parameters, and hits submit. When I see the submission, I have to call a C program, passing it the form parameters. The C program then outputs JavaScript (which codes for an SVG image). This image must then appear (preferably in a modal) at the client's browser.
I haven't been able to find an existing Joomla extension which does anything like this, or which I can modify to do this.
I can write php to call the C code, but how do I get the form data to the php, and arrange for display inside the popup? I've got a general idea of how I can use jQuery to respond to a form submission and to generate a popup using data from a form (along the lines of http://www.sohtanaka.com/web-design/inline-modal-window-w-css-and-jquery/). However, I can't see that this is relevant. The main problem is that I have to generate the SVG JavaScript on the server, and I can't influence this from the client jQuery code (I think). The client code can't, I think, do much more than style the popup.
Any pointers appreciated.
Couldn't you do something like this...
HTML
<form id="svgGetter">
//form content
</form>
<div id="svgSetter"></div>
jQuery
$('form#svgGetter').submit(function() {
alert("Posting data...");
$.post("yoursvgcreater.php", $(this).serialize(), function(data) {
if (data)
{
alert("It worked.");
$('svgSetter').wrapInner('<svg />').append(data);
}
});
return false;
});
I have a image upload form which adds an image to my server, although I'm wanting to load the information through jQuery ajax so the form doesn't refresh on submit.
At the moment I have
$('.img-form').submit(function(e) {
e.preventDefault();
$.post(document.href, $(".img-form").serialize());
});
Which seems to post the document, although i need to get it to call my ImageUpload() function from the PHP once I've pressed the submit.
My php function is called something like this,
<?php $Users->TutorialImageUpload(); ?>
If I understood correctly, you wish to upload an image without refreshing the page, and call your imageUpload() function.
As mentioned in the comments, you cannot upload in such a manner, however, what you could do
is put your upload form and code in a seperate php file and include it in the page as an iframe. This would upload your files withough refreshing the page.
I need to display an html page and within the page is a div into which I want to echo the output of a PHP page.
While the PHP page is being fetched and prepared I want to display a "Loading" msg and a temporary gif.
I have the html code working
and I have the PHP code working/echo'ing.
How do I echo the contents of the PHP page to replace the original contents of the Div.?
(I guess - with an include:file and an innerhtml statement, but how/where?)
A Javascript solution would be fine.
Thanks
Add a div to your page with the image in it, then using jQuery:
$('#myDiv').load('mypage.php');
You're essentially looking to make an asynchoronous call to your php script once the page is loading, so JavaScript is your friend.
When the page loads, include the loading message and the temporary gif, then do an ajax call to your php script and insert the response into the relevant div.
As #Sjoerd points out - jQuery will do this for you nicely.
take a look into ajax:
The Low-down
Using ajax with jQuery