如何在php codeigniter中显示弹出窗口

时间:2015-03-24 06:20:52

标签: php

这是使用codeigniter framework在php中显示弹出窗口和编辑细节的代码。我们编写了相应的代码,用于显示弹出窗口和编辑个别细节,但它不起作用。我们附加了视图代码。请纠正它。     jquery的/外部/ jquery的/的jquery.js“>

         <div id="addLand" title="Land Details">
        <table width="87%" border="1">
        <?php
            $attr= array('name' => 'frmSave', 'id' => 'frmSave');
            echo form_open('#',$attr);
        ?>
           <input name="txtLandId" type="hidden" id="txtLandId" size="20"/>   
          <tr>
            <td width="57%">Name <span  class="errMsgMark">*</span></td>
            <td width="43%"><label>
              <input name="txt_lname" type="text" id="txt_lname" tabindex="1" size="20" maxlength="50"/>
            </label></td>
          </tr>
         <tr>
            <td>Location<span  class="errMsgMark">*</span></td>
            <td><input name="txt_location" type="text" id="txt_location" tabindex="5" size="20" maxlength="10"/></td>
          </tr>
          <tr>
            <td colspan="2"><div id="ERRmsg1"></div></td>
            </tr>
            <tr>
            <td><input type="button" name="ButSave" value="Save" id="ButSave" class="buttonCSS1"/></td>
            <td><input type="button" name="ButCancel" value="Close" id="ButCancel" class="buttonCSS1" tabindex="9"/></td>
            </tr>
        <?php
            echo form_close();
        ?>
        </table>
        </div>
<table width="100%" border="1" class="mGrid">
          <tr>
            <th width="6%"><div align="center">Sl.No</div></th>
            <th width="22%"><div align="center">Name</div></th>
            <th width="23%"><div align="center">Location</div></th>
            <th colspan="3"><input type="button" name="ButNew" value="New" id="ButNew" class="buttonCSS1"/></th>
            </tr>
            <tr>
    <?php
                $str1='';
                $y=0;
                $i=0;
                //$LandM_Details=array();
                //print_r($LandM_Details);
                foreach($LandM_Details->result() as $row)
                {
                    $y=$i+1;  
                    $str1.= '<tr><td width="5%" height="23" >'.$y.'</td>';
                    $str1.= '<td width="25%" height="23">'.$row->land_name.'</td>';
                    $str1.= '<td width="15%" height="23" >'.$row->land_location.'</td>';
                    $str1.= '<td align=center><a href=# onclick=EditDetails('.$row->id.');>Edit</a></td>';
                    $i++;
                }
                echo $str1;
    ?>
    </tr>
    </table>
    <script language="javascript" type="text/javascript">
        $(function(){

            $('#addLand').dialog({
                autoOpen: false,
                modal: true,
                resizable:false,
                width:'370px'
            });
$('#ButNew').click(function(){
                            //document.getElementByName('txt_lname').value='';
                            //document.getElementByName('txt_id').value=0;
                            //$('#txt_lname').val('');
                            //$('#txt_location').val('');
                            $('#addLand').dialog('open');
            });

        $('#ButSave').click(function(){           //Save land details........
                    var values = $("#frmSave").serialize();
                    alert(values);
                            $.ajax({
                               type: "POST",
                               url: "<?php echo base_url();?>index.php/home/get_land_details",
                               data: values,
                               dataType: "json",
                               success: function(msg){
                                alert(msg.success);
                                    if(msg.success=="1")
                                    {
                                        $('#ERRmsg1').html(msg.val);
                                        $("#addLand").dialog('close');
                                    }
                                    else
                                    {
                                         $("#ERRmsg1").html(msg.val);
                                    }
                                },
                               error: function(jqXHR, textStatus, errorThrown) 
                               { 
                                     alert( jqXHR.responseText);
                               }
                            });

              });
              function EditDetails(v1)     //Edit Land details...........
                {       
                            document.getElementById('txtLandId').value=v1;
                            //document.getElementById('txt_location').value=v2;
                                var values = $("#frmSave").serialize();
                                alert(values);
                                $.ajax({
                                       type: "POST",
                                       url: "<?php echo base_url();?>index.php/home/get_land_details",
                                       data: values,
                                       dataType: "json",
                                       success: function(msg){
                                       alert(msg.success);
                                            $('#txt_lname').val(msg.land_name);
                                            $('#txt_location').val(msg.land_location);
                                            //$('#addLand').dialog('open');                         
                                        },
                                       error: function(jqXHR, textStatus, errorThrown) 
                                        { 
                                             alert( jqXHR.responseText);
                                        }
                                    });

                            }
    });
    </script>         here

0 个答案:

没有答案