Function statring function : IS there a quicker way?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
facets
Forum Contributor
Posts: 273
Joined: Wed Apr 13, 2005 1:53 am
Location: Detroit

Function statring function : IS there a quicker way?

Post by facets »

Hi All,

As the subject suggests, I'm trying to popup a window from a submit button (there are many of them on the same page).
The following code is working fine, but seems over complicated.

Any ideas on how I could 'Take a shortcut' to do the same thing?

Code: Select all

// Action variable for switch

$action = ($_POST['action']);

//Click submit button

<input type="submit" name="viewFaceStock" class="btn" value="View Face Stock Specs">

//Recieve input and trigger popup passing stockId

if ($_POST['viewFaceStock']) {
        view($_POST['stockId']);
}

function view($stockId) {
echo "<script language=\"javascript\">var newWindow = window.open
('".$_SERVER['PHP_SELF']."?action=viewFaceStock&stockId=".$stockId."','','scrollbars=yes,status=yes,windowX=10,windowY=10,width=440,height=550')</script>";
}


switch($action) {
    case "viewFaceStock": fnViewFaceStockSpec(); break;
    default: viewFaceStockSummary(); break;
   }
User avatar
trukfixer
Forum Contributor
Posts: 174
Joined: Fri May 21, 2004 3:14 pm
Location: Miami, Florida, USA

Re: Function statring function : IS there a quicker way?

Post by trukfixer »

facets wrote:Hi All,

As the subject suggests, I'm trying to popup a window from a submit button (there are many of them on the same page).
The following code is working fine, but seems over complicated.

Any ideas on how I could 'Take a shortcut' to do the same thing?

Code: Select all

// Action variable for switch

$action = ($_POST['action']);

//Click submit button

<input type="submit" name="viewFaceStock" class="btn" value="View Face Stock Specs">

//Recieve input and trigger popup passing stockId

if ($_POST['viewFaceStock']) {
        view($_POST['stockId']);
}

function view($stockId) {
echo "<script language="javascript">var newWindow = window.open
('".$_SERVER['PHP_SELF']."?action=viewFaceStock&stockId=".$stockId."','','scrollbars=yes,status=yes,windowX=10,windowY=10,width=440,height=550')</script>";
}


switch($action) {
    case "viewFaceStock": fnViewFaceStockSpec(); break;
    default: viewFaceStockSummary(); break;
   }

Code: Select all

<input type="submit" name="viewFaceStock" class="btn" value="View Face Stock Specs" OnClick=window.open('".$_SERVER['PHP_SELF']."?action=viewFaceStock&stockId=".$stockId."','','scrollbars=yes,status=yes,windowX=10,windowY=10,width=440,height=550')>


or something to that effect :)
Post Reply