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;
}
?>
問題がアラートであるです。ありがとう
どうやって動かないのですか?発射していない、「未定義」と表示してエラーを投げていますか? – Igor
それは発砲していないからではありませんが、$ id = "newdrop"はjs @ GrailsGuyによって取得されません – look4php