Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Button = new page!!?? Help Pls

Status
Not open for further replies.

Forri

Programmer
Joined
Oct 29, 2003
Messages
479
Location
MT
Hi all

Well i would like that when i press a button on the index page it first goes through a script which determines which button was pressed and if a certain button is pressed than a new window opens with the desired location!

Is this possible?

Thanks
ncik
 
Absolutely possible!!

I don't have any idea whether you know how data is send through form and stuff.

But, make the button as a '"Submit" type of a form, give the form action to the script which decides which button is pressed and processes accordingly.

Code:
// index page
<form action="script1.php" method="POST">
<input type="Submit" name="submit" value="button1">
</form>

// script1.php
<?
if ( isset($_POST["submit"] && $_POST["submit"] == "button1" ) {
  echo "button1 is pressed" ;
...
...
}

?>


--------------------------------------------------------------------------
I never set a goal because u never know whats going to happen tommorow.
 
Is this a JavaScript question your asking ?
 
Thanks for your response:

Spookie:

I know that part! thanks anyways

ingresman:

I don't know exactly how i can go about it; that's why i asked! do you think that javascript will do the trick? if so how i can implement it!

Thanks once again
Ncik
 
You will have to use the combination of both ie PHP and JavaScript.

Determine which button is pressed and form a url using PHP 'switch case' or 'if else statment'.
use window.open property of javascript with the argument of the url formed using PHP.



--------------------------------------------------------------------------
I never set a goal because u never know whats going to happen tommorow.
 
You can put an onclick=jsfunction() event into the button which when the button is clicked it invokes a JavaScript function called,in this case, jsfunction. so if you can make the choice in JavaScript you don't need to go back to the server to run the php, as spookie says you just execute window.open wit the correct URL and a new window will open.
It's all straight forward but you will wither have to as kthe Javascript forum or do a bit of digging on the web about JavaScript events try webmonkey.com, as a starter:
<script>
function clicked() {
window.open(myurl.com);
}
</script>
..
..
.
<button id=btn1 ...onclick="clicked()">

You can pass parameters into the function or check the callng id to see if one of many buttons got pressed
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top