0

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' );
		
		
         	document.myform.submit();
	});

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

print_r($_REQUEST['Preview']);

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?

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by McLaren
0
//print_r() is to print an array. Preview is NOT an array. 
//You can print the entire $_REQUEST array:
print_r($_REQUEST);

//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(); */
	});
0

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.