gpt4 book ai didi

javascript - 如何隐藏和显示另一个选择选项栏的选择选项

转载 作者:行者123 更新时间:2023-12-02 18:20:04 25 4
gpt4 key购买 nike

我很乐意在下面找到这个挑战的解决方案。我想要一种情况,当我选择医生选项时,它会隐藏专家列表,当我选择专家时,它会显示专家列表。谢谢

    <tr><td colspan=2 ><strong>Doctor Locator</strong></td></tr>
<tr><td>
<?php
$doc = 'Doctors';
$spel = 'Specialist';
$medic = array($doc, $spel);
sort ($medic);
echo "<select>";
foreach ($medic as $m)
{
echo "<option value=\"$m\">$m</option>";
}
echo "</select> <br/> ";

?>

<select name="txt_specialize" style="width: 400px; height: 25px">
<?php
$specialist = array('Surgeon','Neurosurgeon','','Neurologist','Occupational Medicine Physician','Ophthalmologist',
'Oral and Maxillofacial Surgeon','Pathologist','Psychiatrist','Podiatrist','Nephrologist','Otolaryngologist',
'Internal Medicine Physician','Gastroenterologist','Emergency Physicians','Hermatologist','Dermatologist',
'Anesthesiologist','Immunologist','Orthopaedic Surgeon','Radiation Onconlogist','Gynaecologist','Dentist',
'Optician','Cardiologist','Pediatrician','Urologist','Diagnostic Radiologist','Pulmonary Medicine Physician',
'Rheumatologist','Plastic Surgeon');
sort ($specialist);
foreach ($specialist as $s)
{
echo "<option value=\"$s\">$s</option>";
}
echo "</select>"

?>
</td></tr>
<tr><td>

最佳答案

您可以使用 jQuery 轻松地做到这一点。如果你给第一个选择一个“type”的id,你可以添加以下jQuery:

        $(document).ready(function(){

$("select[name='txt_specialize']").hide();

$("select#type").change(function(){
if($(this).val() == 'Doctor')
{
$("select[name='txt_specialize']").hide();
}
else
$("select[name='txt_specialize']").show();
});

});

关于javascript - 如何隐藏和显示另一个选择选项栏的选择选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18916577/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com