2016-11-11 1 views
2

このスクリプトでonChangeを書く方法は誰ですか? 私は私のスクリプト Javascriptのコードにこれらのphpcodeを追加したい:こここのスクリプトでonChangeを書き込む方法誰でも私に正しい構文を教えてもらえますか

ih+='<div class="form-group drop_bottom" id="select_one_'+extra_num+'"><select name="sizes_'+extra_num+'" style="position:absolute;top:0px;left:0px;width:200px; height:25px;line-height:20px;margin:0;padding:0;" id="sizes_'+extra_num+'" onChange="+document.getElementById("displayValue").value=this.options[this.selectedIndex].text;+document.getElementById("sizes_'+extra_num+'").value=this.options[this.selectedIndex].value;this_total(this,1);grand_total(this)"><option value="0">Select One</option> 

は、PHPのコードです:

<div style="position:relative;width:200px;height:25px;border:0;padding:0;margin:0;" id="select_one_0" class="form-group drop_bottom"> 

    <select name="sizes_0" id="sizes_0" style="position:absolute;top:0px;left:0px;width:200px; height:25px;line-height:20px;margin:0;padding:0;" onChange="document.getElementById('displayValue').value=this.options[this.selectedIndex].text; document.getElementById('select_sizes_0').value=this.options[this.selectedIndex].value;this_total(this,1);grand_total(this)" >  <option value="0" >Select One</option> 
      <?php 
    $get_banner_tyes = Get_banner_tyes(); 
      if($get_banner_tyes != false) 
      { while($row_get_banner_tyes = mysql_fetch_array($get_banner_tyes)) 
       { 
      ?> 
      <option value="<?php echo $row_get_banner_tyes['banner_type_value'] * $_SESSION['secondary_currency_value']; ?>_<?php echo $row_get_banner_tyes['banner_type_id']; ?>"><?php echo $row_get_banner_tyes['banner_type_name']; ?></option> 

      <?php } ?> 
       <?php } 
      ?>   

        </select> 
    <input name="displayValue" placeholder="Width*Height value" id="displayValue" style="position:absolute;top:0px;left:0px;width:183px;width:180px\9;#width:180px;height:23px; height:21px\9;#height:18px;border:1px solid #556;" onFocus="this.select()" type="text"> 
<input name="idValue" id="select_sizes_0" type="hidden" > 
     <input type="hidden" name="select_sizes_0" id="select_sizes_0"> 
    <input type="hidden" name="select_elements_0" id="select_elements_0"></div> 
+0

ベストプラクティスに従う関数を記述する必要があります。その関数を呼び出します。 –

+0

このスクリプトでは、onchange関数が取得されません。私の構文が正しいとは思わない – sypr

答えて

1

使用単一引用符の代わりに二重引用符と引用符の前にバックスラッシュを追加します。

onChange="(document.getElementById(\'displayValue\').value=this.options[this.selectedIndex].text; document.getElementById(\'sizes_'+extra_num+'\').value=this.options[this.selectedIndex].value;this_total(this,1);grand_total(this);)" 
関連する問題