如何在javascript

时间:2016-06-22 06:25:47

标签: javascript php html

image 1 image 2

此div标签包含以下内容。&#34;命名Individual Branch&#34; <div hidden name = "divT" id = "divT" >Hi</div> <html> 我想在一个单独的div中使用Name。 这些都是动态的,来自数据库 以下是我的javascript代码

<?php>
if ($Select=="Policy"){
$qry = "select DISTINCT l.np1_proposal POLICY , A.aag_agcode  AGENT , B.pcl_locatcode CODE , BR.pcl_locatdesc LOCATION ,p.pcl_channel CHANNEL , l.np2_setno 
  FROM lnp2_policymastr l , laag_agent A ,  pcl_complocation B , pcl_complocation BR , pcl_complocation p
  where l.np1_proposal= '$Policy' and A.aag_agcode=l.aag_agcode AND B.pcl_locatcode =A.pcl_locatcode and B.pcl_locatcode=BR.pcl_locatcode and 
   p.pcl_locatcode=BR.pcl_locatcode and l.np2_setno = (select max(np2_setno) from lnp2_policymastr where np1_proposal = '$Policy')  ";      
      $stmt = OCIParse($conn,$qry);

      OCIDefineByName($stmt,"CHANNEL",$channel); 
     OCIDefineByName($stmt,"LOCATION",$channe);       
      OCIExecute($stmt);
      OCIFETCH($stmt);
     //echo $channe;
     //OCIDefineByName($stmt,"LOCATION",$channe);  

     $q1="select  A.NPH_FULLNAME NAME , B.NPH_CODE CODE 
  FROM  lnph_pholder A , LNU1_UNDERWRITI B
  where B.NP1_PROPOSAL='$Policy' and A.NPH_CODE=B.NPH_CODE";

  $t = OCIParse($conn,$q1);

      OCIDefineByName($t,"NAME",$name); 
     //OCIDefineByName($stmt,"LOCATION",$channe);     
      OCIExecute($t);
      OCIFETCH($t);
      echo nl2br("\n$name");
      //echo $name;
// echo $_SESSION['$name'];
  }
?>

function showName(政策,选择) {

//警报(&#34;您好&#34 + +选择策略);

if (Policy == "") {
        document.getElementById("divT").innerHTML = "";
        return;
    } else { 
        if (window.XMLHttpRequest) {
            // code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp = new XMLHttpRequest();
    //alert("Hi");

        } else {
            // code for IE6, IE5
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");


            }
        xmlhttp.onreadystatechange = function() {
    //alert("Hi3" + xmlhttp.readyState + xmlhttp.status  );

            if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                //alert(xmlhttp.responseText);
                document.getElementById("divT").innerHTML = xmlhttp.responseText;
                document.getElementById("divT").style.display ='block';
                //document.getElementById("divT1").style.display ='block';
        //  alert(xmlhttp.responseText);
            }
        };
        xmlhttp.open("GET","query.php?policy="+Policy+'&select='+Select,true);
        xmlhttp.send();
    }
}

<tr>
<td><h4>Lookup Category: * 

  <select  id= "email" name="email" style="width: 10px !important; min-width: 170px; max-width: 170px;" > 


<option value="">Please select:</option>
  <option value="Policy">Policy<p></option>
  <option value="Agent">Agent</option>
  <option value="CNIC">CNIC</option>
  <option value="Branch">Branch</option>
</select>
</td>



    <td ><div hidden name = "divT"  id = "divT" >Hi</div></td>

     <div> <span class="error"> <?php ?></div></span> 

     </tr>

2 个答案:

答案 0 :(得分:0)

您可以按单词

获取innerText adn split文字
var val = document.getElementById("divName").innerText;
val = val.split("Individual");
var name = val[0];

答案 1 :(得分:0)

我写了这段代码,我的问题解决了:P

std::result_of<decltype(&Bar::f)(Bar*)>::type y2;