Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi I have got a form with two submit buttons. one button is to update the content in my select list and the other one to to send the form data.if the second button clicked i have to load the results in a new tab. but when i used base target it is opening new tab even if i put the condition like this inside my form
PHP
<?php if (isset($_POST['empList'])):??>
<base target="_self">
<?php endif;??>
<?php if (isset($_POST['Report'])):??>
<base target="_Blank">
<?php endif;??>
Posted
Updated 13-Oct-12 12:33pm
v2
Comments
project virus 15-Oct-12 7:08am    
Please paste tour whole code

1 solution

here is what I understand....

you have got 2 Submit button in a form.
> When clicked on 1st it should load the active page in the same window and
> when clicked on 2nd it should load active page in new window.

You are trying achieve above behavior using below PHP Code...
PHP
<?php if (isset($_POST['empList'])):??>
<base target="_self">
<?php endif;??>
<?php if (isset($_POST['Report'])):??>
<base target="_Blank">
<?php endif;??>


I think there is a bug in your code. When page is initially loaded base tag will not be set, because both if conditions will be false.

You have to write client side code to achieve your said behavior. Following is sample code...
XML
<form>
    <input type="Submit" value="Self" onclick="document.forms[0].target='_self';">
    <input type="Submit" value="New Window" onclick="document.forms[0].target='_blank';">
</form>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900