Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_Related Related Topics sp_TopicIcon
pass value from jqgrid to php and dispaly the value based on the value passed
Tags: jqgridphp
23/01/2014
12:43
Avatar
franklin
New Member
Members
Forum Posts: 2
Member Since:
23/01/2014
sp_UserOfflineSmall Offline

hi, i have the below two php files and i trying to pass the value from the selected option to the base php file and display the information based on the passed file.

fkm_test.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>ITRS FKMS</title>
 
<link rel="stylesheet" type="text/css" media="screen" href="../js/jquery-ui-1.10.3.custom_blackGreen/jquery-ui-1.10.3.custom/css/trontastic/jquery-ui-1.10.3.custom.min.css" />
<link rel="stylesheet" type="text/css" media="screen" href="../js/jquery.jqGrid-4.5.2/css/ui.jqgrid.css" />
 
 
<script src="../js/jquery-ui-1.10.0.custom/jquery-1.9.0.min.js" type="text/javascript"></script>
<script src="../js/jquery.jqGrid-4.5.2/js/i18n/grid.locale-en.js" type="text/javascript"></script>
<script src="../js/jquery.jqGrid-4.5.2/js/jquery.jqGrid.min.js" type="text/javascript"></script>

<script type="text/javascript">
function fkm(Application) {
    var app = document.getElementById("myApp").selectedIndex;
    var app_selected = document.getElementsByTagName("option")[app].value;
    alert (app_selected);
    //alert(document.getElementsByTagName("option")[app].value);
    var lastSel
    $("#list").jqGrid({

        url: "fkm_display.php?app=$app_selected",
        editurl: "fkmedit.php",
        datatype: "json",
        mtype: "GET",
        colNames: ["App", "Pattern Type", "Pattern", "Rank", "AMRS", "EMEA", "APAC", "Audit", "ID", "Alert Type", "Comments"],
        colModel: [
            { name: "division", width: 75 , editable: true},
            { name: "pattern_type", width: 90, editable: true, edittype:"select",formatter:'select', editoptions:{value:"BASIC:BASIC;REGEXP:REGEXP;REGEXP_IGNORE_CASE:REGEXP_IGNORE_CASE" } },
            { name: "pattern", width: 650, editable: true },
            { name: "rank", width: 50 },
            { name: "amrs_active", width: 40, editable: true, edittype:"select",formatter:'select', editoptions:{value:"1:Active;0: " } },
            { name: "emea_active", width: 40, editable: true, edittype:"select",formatter:'select', editoptions:{value:"1:Active;0: " } },
            { name: "apac_active", width: 40, editable: true, edittype:"select",formatter:'select', editoptions:{value:"1:Active;0: " } },
            { name: "audit", width: 200},
            { name: "id", width: 10, hidden: true},
            { name: "type", width: 20, editable: true, edittype:"select", sorttype:"text",formatter:'select', editoptions:{value:"IGNORE:IGNORE;ALERT:ALERT;WARN:WARN" } },
            { name: "comments", width: 10, editable: true,hidden: true}
        ],
        height: 'auto',
        pager: "#pager",
        rowNum: 90,
        rowList: [10, 20, 30, 60, 90],
        sortname: "rank",
        sortorder: "asc",
        viewrecords: false,
        gridview: true,
        autoencode: true,
        toppager: true,
        grouping:true,
        groupingView : {
                groupField : ['type'],
                groupColumnShow : [true],
                groupText : ['<b>{0} - {1} Item(s)</b>']
        },
        caption: "Application FKMs"
    });
jQuery("#list").jqGrid('filterToolbar', { stringResult: true, searchOnEnter: false, defaultSearch: 'cn', ignoreCase: true});
jQuery("#list").jqGrid('navGrid','#pager',{"add":true,"del":true, "edit":true,"search":false,"refresh":true,"view":false, "cloneToTop":true});
};
</script>
 
</head>
<body>
<form id="phpform" name="phpform" method="POST" action="javascript:fkm();">
<select name="Application" id="myApp" >
<option selected="selected">--Select Application--</option>
<?php
include ('app_dbconfig.php');
$sql = "SELECT * FROM applications order by Application asc";
$result = mysql_query($sql) or die("SQL Error 1: " . mysql_error());

while($row=mysql_fetch_assoc($result))
{
echo '<option value="' . $row['Application'] . '">' . $row['Application'] . '</option>';
}
?>
</select>
<input type="submit" name="testing" value="Submit" >
</form>
    <div align="center">
    <table id="list"><tr><td></td></tr></table></div>
    <div id="pager"></div>
</body>
</html>

fkm_display.php

<?php
include("fkm_dbconfig.php");
 
$page = $_GET['page'];
$limit = $_GET['rows'];
$sidx = $_GET['sidx'];
$sord = $_GET['sord'];
$app = $_GET['app_selected'];

if(!$sidx) $sidx =1;
/*
$ops = array(
    'eq'=>'=', //equal
    'ne'=>'<>',//not equal
    'lt'=>'<', //less than
    'le'=>'<=',//less than or equal
    'gt'=>'>', //greater than
    'ge'=>'>=',//greater than or equal
    'bw'=>'LIKE', //begins with
    'bn'=>'NOT LIKE', //doesn't begin with
    'in'=>'LIKE', //is in
    'ni'=>'NOT LIKE', //is not in
    'ew'=>'LIKE', //ends with
    'en'=>'NOT LIKE', //doesn't end with
    'cn'=>'LIKE', // contains
    'nc'=>'NOT LIKE'  //doesn't contain
);
function getWhereClause($col, $oper, $val){
    global $ops;
    if($oper == 'bw' || $oper == 'bn') $val .= '%';
    if($oper == 'ew' || $oper == 'en' ) $val = '%'.$val;
    if($oper == 'cn' || $oper == 'nc' || $oper == 'in' || $oper == 'ni') $val = '%'.$val.'%';
    return " WHERE $col {$ops[$oper]} '$val' ";

}
$where = "";
$searchField = isset($_GET['searchField']) ? $_GET['searchField'] : false;
$searchOper = isset($_GET['searchOper']) ? $_GET['searchOper']: false;
$searchString = isset($_GET['searchString']) ? $_GET['searchString'] : false;
if ($_GET['_search'] == 'true') {
    $where = getWhereClause($searchField,$searchOper,$searchString);
}
#$where = "";
$port=isset($_GET['searchString']);
*/
$result = mysql_query("SELECT COUNT(*) AS count FROM global_itrs_fkms");
$row = mysql_fetch_array($result,MYSQL_ASSOC);
$count = $row['count'];
$total_pages=0;
if( $count >0 ) {
        $total_pages = ceil($count/$limit);
} else {
        $total_pages = 0;
}
if ($page > $total_pages) $page=$total_pages;
$start = $limit*$page - $limit; // do not put $limit*($page - 1)

$filterResultsJSON = json_decode($_REQUEST['filters']);

if($filterResultsJSON){
$filterArray = get_object_vars($filterResultsJSON);

$filterResultsJSON = json_decode($_REQUEST['filters']);

$filterArray = get_object_vars($filterResultsJSON);}
$SQL = "select division,pattern_type,pattern,rank,amrs_active,emea_active,apac_active,concat(audit,' ', timestamp) as audit,id,type from global_itrs_fkms";

$counter = 0;

while($counter < count($filterArray['rules']))
{

$filterRules = get_object_vars($filterArray['rules'][$counter]);

if($counter == 0){
$SQL .= ' WHERE ' . division = '$app' . $filterRules['field'] . ' LIKE "%' . $filterRules['data'] . '%"';
}

else {
$SQL .= ' AND ' . $filterRules['field'] . ' LIKE "%' . $filterRules['data'] . '%"';
}
$counter++;
}

$SQL .= " order by $sidx $sord LIMIT $start, $limit";
echo $SQL;

$result = mysql_query( $SQL ) or die("Couldn t execute query.".mysql_error());

$responce['total'] = $total_pages;
$responce['page'] = $page;
$responce['records'] = $count;
$i=0;
while($row = mysql_fetch_array($result,MYSQL_ASSOC)) {
    $responce['rows'][$i]['id']=$row[id];
    $responce['rows']      [$i]['cell']=array($row[division],$row[pattern_type],$row[pattern],$row[rank],$row[amrs_active],$row[emea_active],$row[apac_active],$row[audit],$row[id],$row[type]);
    $i++;
}        
echo json_encode($responce);

24/01/2014
20:35
Avatar
Lonewolf217
Member
Members
Forum Posts: 32
Member Since:
22/05/2013
sp_UserOfflineSmall Offline

what selected option. are you referring to the select elements in edit mode for a couple of your rows where you are trying to save the new value ?

27/01/2014
11:54
Avatar
franklin
New Member
Members
Forum Posts: 2
Member Since:
23/01/2014
sp_UserOfflineSmall Offline

Lonewolf217 said:what selected option. are you referring to the select elements in edit mode for a couple of your rows where you are trying to save the new value ?


Hi,

In fkm_test.php changed the following :

url: "fkm_display.php?app=$app_selected", ==> url: "fkm_display.php?app="+app_selected,

In fkm_display.php removed "echo $SQL;" and it worked.

Now i have another issue.

From the drop down if i select the Application and hit Submit its showing the information.

After the information is populated, if i reselect another application and hit Submit its not loading the new information. Only old information is present. how do i reload the grid when i re-submit the application names 'n' number of times.

-Franklin

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
55 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information