Click here to Skip to main content
13,556,206 members
Rate this:
Please Sign up or sign in to 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 if (isset($_POST['empList'])):??>
<base target="_self">
<?php endif;??>
<?php if (isset($_POST['Report'])):??>
<base target="_Blank">
<?php endif;??>
Posted 13-Oct-12 12:30pm
Updated 13-Oct-12 12:33pm
project virus 15-Oct-12 7:08am
Please paste tour whole code

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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 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...
    <input type="Submit" value="Self" onclick="document.forms[0].target='_self';">
    <input type="Submit" value="New Window" onclick="document.forms[0].target='_blank';">

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03-2016 | 2.8.180515.1 | Last Updated 17 Oct 2012
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100