简体   繁体   English

如何从另一个文件中的php和javascript获取价值

[英]How to get value from php and javascript in another file

file1.php file1.php

 <select class="combo-boxs" name="doc_level" id="combo_doc">
    <option value="-">Choose Document Level</option>
    <?php 

       $t=mysql_query("select * from dokumen_level limit 6",$con);

       while($n=mysql_fetch_array($t)){
            if($dok_lvl==$n['nama_dok_level']){$selected='selected';}else{$selected='';}
            $list_dok_level.='<option value="'.$n['nama_dok_level'].'" '.$selected.'>'.$n['nama_dok_level'].'</option>';
            }

            echo $list_dok_level;
            ?>
            </select>


<input  type="text" name="no_document" id="no_document" size="30" disabled="disabled" />


   <script>
     $("select").change(function () {  
       var str =$("#combo_issuer").val();
       var doc =$("#combo_doc").val();

 if(str!="" && doc!=""){ 
    $.get("get_name.php", {issuer: str, doc_lvl: doc}, function(data){
    //get the value from the get_name.php file and asign to display_name text filed
    $("#no_document").val(data.split("-")[0]);
   });
 }
 })
  .change();

 </script>

file2.php file2.php

 $ID = $_GET['issuer'];  
 $doc_lvl = $_GET['doc_lvl'];     

 $sql1= mysql_query("SELECT MAX(id_dokumen) AS maxid from dokumen_internal WHERE issuer='".$ID."'");
 $m=mysql_fetch_array($sql1);
 $id_dok_max=$m['maxid'];

 $sql3 = mysql_query("SELECT substring(no_dokumen, 11, 3) AS nomor FROM dokumen_internal WHERE id_dokumen='$id_dok_max' ") or die(mysql_error());
                                   $n=mysql_fetch_array($sql3);
                                   $nomor_max=$n['nomor'];
                                   $no=$nomor_max++;
                                   $no_inc=sprintf("%03s",$nomor_max);

 $sql= mysql_query("SELECT * FROM departemen WHERE id_departemen = '".$ID."'");
 $row = mysql_fetch_array($sql);
 $display="SS/".$doc_lvl."/".$row['id_departemen'].$no_inc;
 echo  "SS/".$doc_lvl."/".$row['id_departemen'].$no_inc;

This code was succesfully display what i want.. but i can't get text from that field from no_document 这段代码成功显示了我想要的..但​​是我无法从no_document的那个字段中获取文本

<input  type="text" name="no_document" id="no_document" size="30" disabled="disabled" />

i want get that value for insert .. May you know where is the bug ? 我想获取该插入值。你可以知道错误在哪里吗? .. Thank you so much .. .. 非常感谢 ..

You must set the field with readonly properties, if you set disabled properties on input tag then it will not be posted. 您必须将字段设置为只读属性,如果在输入标签上设置了禁用的属性,则不会发布该字段。 ex: 例如:

<input  type="text" name="no_document" id="no_document" size="30" readonly="readonly" />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM