EasyUI Forum
November 03, 2025, 08:21:26 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: [SOLVED] Problem with Master Detail Datagrid  (Read 14185 times)
MB34
Newbie
*
Posts: 20


View Profile
« on: April 28, 2015, 03:03:33 PM »

URL: http://www.scic.com/files/website_gatekeeper/index.html

I'm the master-detail example and cannot access the data in the form in the saveItem() function, the save_gatekeeper and update_gatekeeper call DO NOT get any parameters.
Here is the code for the show_form.php file:

Code:
<?php 
    $x   
$_REQUEST['IND'];
    
$pc  $_REQUEST['PC'];
    
$st  $_REQUEST['ST'];
    
$typ $_REQUEST['TYP'];
    
$us_states = array(
        
'OL' => 'OL',
        
'WB' => 'WB',
        
'AL' => 'Alabama',
        
'AK' => 'Alaska',
        
'AZ' => 'Arizona',
        
'AR' => 'Arkansas',
        
'CA' => 'California',
        
'CO' => 'Colorado',
        
'CT' => 'Connecticut',
        
'DE' => 'Delaware',
        
'DC' => 'District of Columbia',
        
'FL' => 'Florida',
        
'GA' => 'Georgia',
        
'HI' => 'Hawaii',
        
'ID' => 'Idaho',
        
'IL' => 'Illinois',
        
'IN' => 'Indiana',
        
'IA' => 'Iowa',
        
'KS' => 'Kansas',
        
'KY' => 'Kentucky',
        
'LA' => 'Louisiana',
        
'ME' => 'Maine',
        
'MD' => 'Maryland',
        
'MA' => 'Massachusetts',
        
'MI' => 'Michigan',
        
'MN' => 'Minnesota',
        
'MS' => 'Mississippi',
        
'MO' => 'Missouri',
        
'MT' => 'Montana',
        
'NE' => 'Nebraska',
        
'NV' => 'Nevada',
        
'NH' => 'New Hampshire',
        
'NJ' => 'New Jersey',
        
'NM' => 'New Mexico',
        
'NY' => 'New York',
        
'NC' => 'North Carolina',
        
'ND' => 'North Dakota',
        
'OH' => 'Ohio',
        
'OK' => 'Oklahoma',
        
'OR' => 'Oregon',
        
'PA' => 'Pennsylvania',
        
'PR' => 'Puerto Rico',
        
'RI' => 'Rhode Island',
        
'SC' => 'South Carolina',
        
'SD' => 'South Dakota',
        
'TN' => 'Tennessee',
        
'TX' => 'Texas',
        
'UT' => 'Utah',
        
'VI' => 'US Virgin Islands',
        
'VT' => 'Vermont',
        
'VA' => 'Virginia',
        
'WA' => 'Washington',
        
'WV' => 'West Virginia',
        
'WI' => 'Wisconsin',
        
'WY' => 'Wyoming'
    
);
?>

<form method="POST" >
    <table class="dv-table" style="width:100%;background:#fafafa;padding:5px;margin-top:5px;">
        <tr>
            <td>Program Code</td>
            <td><input name="prg_code" id="PRG_CODE" class="easyui-validatebox" required="true" value="<?php echo $pc?>" /></td>
            <td>State</td>
            <td>
                <select class="unstyled" required="true" name="state" id="">
<?php
    
foreach($us_states as $key => $value) {
?>
       
             <option value="<?php echo $key?>" <?php echo ($key==$st"selected":""?>><?php echo $value;?></option>
<?php        
    
}
?>

                </select>
            </td>
            <td>Course Type</td>
            <td>
                <select required="true" name="type">
                    <option value="0" <?php echo ($typ=="0""selected":""); ?>>Online</option>
                    <option value="1" <?php echo ($typ=="1""selected":""); ?>>Classroom</option>
                    <option value="2" <?php echo ($typ=="2""selected":""); ?>>Webinar</option>
                </select>
            </td>
        </tr>
        <tr>
            <td colspan="6">Text</td>
        </tr>
        <tr>
            <td colspan="6"><textarea id="text_<?php echo $x;?>" class="jha_ta" cols="110" rows="25"></textarea></td>
        </tr>
    </table>
    <div style="padding:5px 0;text-align:right;padding-right:30px">
        <a href="#" class="easyui-linkbutton" iconCls="icon-save" plain="true" onclick="saveItem(<?php echo $x;?>)">Save</a>
        <a href="#" class="easyui-linkbutton" iconCls="icon-cancel" plain="true" onclick="cancelItem(<?php echo $x;?>)">Cancel</a>
    </div>
</form>

Here's the code for the update_gatekeeper.php file:

Code:
<?php
    $id          
intval($_POST['id']);
    
$prg_code    $_POST['prg_code'];
    
$state       $_POST['state'];
    
$course_type $_POST['type'];
    
$text        $_POST['text'];

    if(
strpos($_SERVER['SERVER_NAME'], 'localhost') > -1) {
        require_once(
$_SERVER['DOCUMENT_ROOT'] ."/db_mysql.php");        
    } else {
        require_once(
$_SERVER['DOCUMENT_ROOT'] . "/store/ajax/db_mysql.php");
    }
    
    
$sql "UPDATE exp_website_gk_text a, exp_website_gk_state b " .
           
"SET a.wgt_text = '".$text."', a.wgt_prg_code = '".$prg_code."', b.wgs_state = '".$state."', b.wgs_type type = ".$course_type.
           
" WHERE a.wgt_rid      = "$id."  AND a.WGT_RID = b.wgs_wgt_rid";
    
    
$result Db::getInstance()->returnQuery($sqlMYSQL_ASSOC);
    
    echo 
json_encode(array(
            
'id' => $id,
            
'prg_code' => $prg_code,
            
'state' => $state,
            
'type' => $course_type,
            
'text' => $text
    
));
?>

And here's the code for the save_gatekeeper.php file:
Code:
<?php

    $id          
intval($_POST['id']);
    
$prg_code    $_POST['prg_code'];
    
$state       $_POST['state'];
    
$course_type $_POST['type'];
    
$text        $_POST['text'];

    if(
strpos($_SERVER['SERVER_NAME'], 'localhost') > -1) {
        require_once(
$_SERVER['DOCUMENT_ROOT'] ."/db_mysql.php");        
    } else {
        require_once(
$_SERVER['DOCUMENT_ROOT'] . "/store/ajax/db_mysql.php");
    }

    
$sql    "BEGIN; ".
              
"INSERT INTO exp_website_gk_text (WGT_PRG_CODE, WGT_TEXT) ".
              
"    VALUES('".$prg_code."', '".$text."'); " .
              
"INSERT INTO exp_website_gk_state (WGS_STATE, WGS_TYPE, WGS_WGT_RID) ".
              
"    VALUES('".$state."', ".$course_type.", LAST_INSERT_ID()); ".
              
"COMMIT;";
    
    
$result Db::getInstance()->query($sql);

    
$sql    "SELECT WGS_WGT_RID id FROM exp_website_gk_text WHERE WGS_RID = ".mysql_insert_id();

    
$result Db::getInstance()->returnQuery($sqlMYSQL_ASSOC);

    echo 
json_encode(array(
        
'id' => $result["id"],
        
'prg_code' => $prg_code,
        
'state' => $state,
        
'type' => $course_type,
        
'text' => $text
    
));
?>

« Last Edit: June 24, 2015, 02:11:49 PM by MB34 » Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: April 28, 2015, 05:20:23 PM »

Please refer to this tutorial http://www.jeasyui.com/tutorial/app/crud3.php
Logged
MB34
Newbie
*
Posts: 20


View Profile
« Reply #2 on: April 29, 2015, 07:05:45 AM »

I believe that is where I got the code from. However...

In the saveItem() function, line 4, I cannot access anything in the form and nothing gets sent to either save_gatekeeper or update_gatekeeper.

Let me also point out that the form's method is POST, yet when you send to update_user you use a GET URL: 'update_user.php?id='+row.id
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #3 on: April 29, 2015, 07:39:34 AM »

You may need to check your code carefully to see if the post is made and sent to server. If no form action is made, your server does not receive any request data.
Logged
MB34
Newbie
*
Posts: 20


View Profile
« Reply #4 on: April 29, 2015, 09:11:39 AM »

I found the problem. The form was incorrect.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!