0
如何選擇僅允許字段「名稱」和「電子郵件」僅在單選按鈕「教授」時顯示?有人可以告訴我如何在jQuery中做到這一點?基於收音機選擇顯示字段
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(':radio[name="addType"]').click(function() {
$('#name-and-email-container').toggle(':not(:radio[value="Professor"]:checked)');
});
</script>
<?php
require_once('inc/dbc1.php');
$pdo = new PDO('mysql:host=####;dbname=###', $username, $password);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sth = $pdo->prepare('
SELECT name
FROM Department
;');
$sth->execute(array());
?>
<div id="popup_name" class="popup_block">
<h2 style="padding:0; margin:0;">Add a:</h2><br>
<form action="inc/add_p_c_validate.php" method="post" id="addition">
Professor<input type="radio" name="addType" value="Professor" />
Course<input type="radio" name="addType" value="Course" />
<div id="name-and-email-container">
<br><br>Name: <input type="text" name="name" /><br>
Department: <select name="deptName" id="deptName"><?php while($row = $sth->fetch(PDO::FETCH_ASSOC)) {echo "<option>".$row['name']." "."</option>";} ?></select>
Email: <input type="text" name="email" /><br></div><br>
<input type="submit" name="submit" />
</form>
</div><!--popup_name-->
請參閱更新的代碼,這是行不通的。我在這裏做錯了什麼? – Jshee 2011-04-20 01:37:55
@ user7000檢查小提琴,它在那裏工作。 – alex 2011-04-20 01:40:11
我知道它在那裏工作:)。你看到更新的代碼有什麼問題嗎?我不知道如何正確實施它? – Jshee 2011-04-20 01:45:46