这是我的代码(表格)。
<tr>
<td class=""> <font color=#00000 />Content Type</td>
<td colspan=""><input id="type" type="radio" name="content_type" value='article' onclick="check_type()">Article </input>
<input id="type" type="radio" name="content_type" value='image' onclick="check_type()">Image </input>
<input id="type" type="radio" name="content_type" value='url' onclick="check_type()">Url </input></td>
</tr>
<tr>
<td width="" class=""> <font color=#00000 />Select Asset</td>
<td width="" colspan=""><select disabled="disabled" id="asset" name="content_asset">
<option value='create_new_content'>select asset</option>
<?php
$dir='../Assets/10/';
if($handle = opendir($dir)){
while(($file = readdir($handle)) !== false){
if($file != "." && $file != ".." && $file != "Thumbs.db"){
$extension = explode('.',$file);
if($extension[1] == 'png' || $extension[1] == 'gif' || $extension[1] == 'jpg'){
echo "<option value=".$file.">".$file."</option>";
}
}
}
closedir($handle);
}
?>
</select></td>
</tr>
单击单选按钮时是否可以执行PHP代码。单击单选按钮时,我使用javascript启用下拉框。
答案 0 :(得分:4)
你必须把php代码放在另一个页面上执行并用AJAX调用它。
编辑:jQuery有一个巧妙的方法。
答案 1 :(得分:0)
PHP在服务器端执行,我不确定,但我怀疑它会在没有页面重新加载的情况下重新渲染任何内容。我认为JavaScript可能有所帮助!
编辑:事实上,看起来右边的相关主题就是你想要的那种信息。
答案 2 :(得分:0)
使用ajax在事件上加载你的php
答案 3 :(得分:0)
不,因为在浏览器上加载此表单时已经执行了PHP代码。
如果您为Article,Image和URL创建三个不同的下拉列表并保持隐藏状态,并根据选择的单选按钮显示相对下拉列表,那会更好。
看起来你正在重新分解/修补代码,所以我不建议你使用jQuery或其他选项。
ATB