2011-07-14 11 views
0

私は2つのPHPページ、htmldisp.phpとclassfn.phpを持っています。 hrmldisp.phpで使用されているアラートが機能していません。実際にはドロップダウン値を与える必要があります。JavaScriptがフィールド値を取得しない

htmldisp.phpは

<?php include("classfn.php"); $obj=new hello;?> 
<script language="javascript"> 
    function submitted(){ 
    var select=document.getElementById('newdrop').value; 
    alert(select);  
} 
</script> 

<?php 
$id="newdrop"; 
echo $obj->hellofn($id); ?> 
<input type="submit" onclick="submitted();" 

classfn.phpが機能していない(選択)

<?php 
    class hello{ 
function hellofn($id){ 

    $s="select `Name`,`Value` from `Days`; 
    $q=mysql_query($s); 
    $p='<td>'.'<select id="$id">'; 
      while($re=mysql_fetch_array($q)){ 
      $value=$re["Value"]; 
      $name=$re["Name"]; 
      $p.='<option value="' . $value . '"' . ($selected==$value ? ' selected="selected"' : '') . '>' . $name . '</option>'; 
      } 
    $p.='</select>'.'</td>'; 

    return $p; 
    } 
      ?> 

問題がアラートであるです。ありがとう

+0

どうやって動かないのですか?発射していない、「未定義」と表示してエラーを投げていますか? – Igor

+0

それは発砲していないからではありませんが、$ id = "newdrop"はjs @ GrailsGuyによって取得されません – look4php

答えて

0

限り、私はあなたが決して関数submittedを呼び出すことができます。あなたのHTMLは完全に形式が違っています。 htmlタグの外にhtmlとjavascriptの束があります。そして、あなたは2つの開口部を持っていますhtml ...

関連する問題