Jump to content

Recommended Posts

i have set up a page with some button on which load different pages up.  the buttons are held within a form and the target is set to blank.  this part is fine for the first set of buttons but i need one of them to reload the page but stay in the same window.  the code that is getting used at the minute looks like this

 

 <input name="reset" type="image" onclick="broad.php" src="admin/images/reset_btn.gif" /> // this is the button i need to refresh the page in same window

<form id="buttons" method="post" enctype="multipart/form-data" action="<?php echo $PHP_SELF; ?>" target="_blank"> // the code for the form

function changeAction(ins)
{var form1 = document.getElementById('buttons');
if(ins==0)
form1.action = "broad_prev.php";
if(ins==1)
form1.action = "broad_send.php";
if(ins==2)
form1.action = "broad.php" ;
form1.submit();
}

 

is it possible to get the button to refresh the page without opening a new window?

Link to comment
https://forums.phpfreaks.com/topic/109375-solved-onclick/
Share on other sites

thanks for the reply it is resetting all the fields on the page but it keeps opening a new window.  the form is set up with the target="_blank" so after each button is clicked it opens a new window.  is there away to get it to ignore this and load the page in the same window or will it have to have come sort of a close window to stop this from happening. 

Link to comment
https://forums.phpfreaks.com/topic/109375-solved-onclick/#findComment-561017
Share on other sites

How about this:

 

function changeAction(ins)

{var form1 = document.getElementById('buttons');

if(ins==0)

form1.action = "broad_prev.php";

if(ins==1)

form1.action = "broad_send.php";

if(ins==2)

form1.action = "broad.php" ;

if(ins==3){

window.location="http://www.yourdomain.com/yourpage.php";

return; //exits function doesnt allow form1.submit() to get executed

}

form1.submit();

 

}

Link to comment
https://forums.phpfreaks.com/topic/109375-solved-onclick/#findComment-561050
Share on other sites

no that didnt work either.  would it be possible to create another form inside the other one and set the target to self so it does not open a new window when the button is clicked.  would the function be able to be duplicated or would the not work.  if my code was like this would it work?

 

<input name="preview" type="image" value="preview"  onclick="changeAction(0)" src="admin/images/preview_btn.gif" alt="Preiview your Layout" align="left" />
        <br />
        <br />
        <input align="left" name="send2" type="image"  src="admin/images/test_btn.gif" alt="Send mailout" />
        <br />
        <br />
        
        <input align="left" name="send" type="image" onclick="changeAction(1)" src="admin/images/list_btn.gif" alt="Send mailout" />
        <br />
            <br /> 
<form id="button" method="post" enctype="multipart/form-data" action="<?php echo $PHP_SELF; ?>" target="_blank">
            <input name="reset" type="image" onclick="broad.php" src="admin/images/reset_btn.gif" />
</form>

function changeAction(ins)
{var form1 = document.getElementById('buttons');
if(ins==0)
form1.action = "broad_prev.php";
if(ins==1)
form1.action = "broad_send.php";
form1.submit();
}

 

the above code for the change action would be for all the other button and this one below would be for the button which has been put in its own form

function changeAction(ins)
{var form2 = document.getElementById('button');
if(ins==0)
form2.action = "window.location.reload()";
form1.submit();
}

 

Link to comment
https://forums.phpfreaks.com/topic/109375-solved-onclick/#findComment-561880
Share on other sites

i have gone down a different road now it would not work that way and i was coming close to punching the comp.  i have still used a form but it now loads a page which removes all the files and then redirects the user to the page they where on to start with.

Link to comment
https://forums.phpfreaks.com/topic/109375-solved-onclick/#findComment-562108
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.