Page 1 of 1

Function statring function : IS there a quicker way?

Posted: Tue May 17, 2005 8:25 am
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;
   }

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

Posted: Tue May 17, 2005 2:56 pm
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 :)