Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Javascript HTML PHP
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
nerv123308
Edited 13-Oct-12 12:33pm
v2
Comments
project virus at 15-Oct-12 7:08am
   
Please paste tour whole code

1 solution

Rate this: bad
good
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...
<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>
  Permalink  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 568
1 OriginalGriff 384
2 George Jonsson 258
3 Abdul Samad KP 135
4 Animesh Datta 130
0 OriginalGriff 6,099
1 Sergey Alexandrovich Kryukov 5,411
2 CPallini 4,770
3 George Jonsson 3,400
4 Gihan Liyanage 2,522


Advertise | Privacy | Mobile
Web03 | 2.8.140916.1 | Last Updated 17 Oct 2012
Copyright © CodeProject, 1999-2014
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