Here is the button:

<input class = "preview" type="submit" name = "Preview" value="Peržiūrėti" />

and here is the submit:

$('input.preview').click(function() {
		$('form').attr( 'target', '_blank' );

So when I submit with jquery, and try to get with php the data


It does not see such index.

But when I change button type to submit and remove javascript code for submitions, then it works. Have you idea, why it works differently when I submit with jquery and what to do?

6 Years
Discussion Span
Last Post by McLaren
//print_r() is to print an array. Preview is NOT an array. 
//You can print the entire $_REQUEST array:

//OR just the Preview item:
echo $_REQUEST['Preview'];

Also, make sure the button is WITHIN the form.

Lastly, if there is more than one form on the page, the first form on the page is likely to be submitted first. I would suggest you give the form in question an id:

<form id="myForm"...>

then use:
$('input.preview').click(function() {
		$('#myForm').attr( 'target', '_blank' ).trigger('submit');
         	/* document.myform.submit(); */

WHen I do

echo $_REQUEST['Preview'];

Still get the error

A PHP Error was encountered

Severity: Notice

Message: Undefined index: Preview

Filename: admin_/info_psl.php

Line Number: 235

Also, make sure the button is WITHIN the form.

It is within a form.

Lastly, if there is more than one form on the page

There is only one form in a page.

But, I can live without javascript submission. Just when I submit, I don't validate the form. But in preview its not that catastrophic. When user submits for saving, then he will see the errors if there is any, so he will not be able to save until he does not fix errors.

Edit: thanks for the response ;)

Edited by McLaren: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.