-1
这应该很容易,不知道为什么它不起作用。如果我删除if!empty,div hide正常工作。如果变量为空,我不想显示该行。隐藏内容,如果变量为空[简单]
[编辑:对不起,留下的index.html出]
的index.html
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
$("input[name='animalvillas']").click(function() {
if ($("#chkYes1").is(":checked")) {
$("#dvanimalvillas").show();
} else {
$("#dvanimalvillas").hide();
}
});
});
</script>
</head>
<form name="create" action="welcome.php" method="post" onsubmit="return validateForm();">
<span><strong>Lodge Villas - Jambo</strong></span><BR />
<label for="chkYes1">
<input type="radio" id="chkYes1" name="animalvillas" value="Y" />
Include
</label>
<label for="chkNo1">
<input type="radio" id="chkNo1" name="animalvillas" value="N" checked />
Exclude
</label>
<hr />
<div id="dvanimalvillas" style="display: none">
$<input type="text" name="animalvillas1" size="3" /> - Value Studio - Standard View (Parking View) <br>
$<input type="text" name="animalvillas2" size="3" /> - Deluxe Studio - Standard View (Water/Pool) <br>
$<input type="text" name="animalvillas3" size="3" /> - Deluxe Studio - Savanna View <br>
</div>
<input type="submit" />
</form>
的welcome.php
<div id="dvanimalvillas" <?php echo ($_POST['animalvillas'] == "N") ? 'style="display:none;"' : '' ; ?>>
<?php if (!empty($animalvillas1)) { ?>$<?php echo $_POST["animalvillas1"]; ?> - Value Studio - Standard View <BR><?php } ?>
<?php if (!empty($animalvillas2)) { ?>$<?php echo $_POST["animalvillas2"]; ?> - Deluxe Studio - Standard View <BR><?php } ?>
<?php if (!empty($animalvillas3)) { ?>$<?php echo $_POST["animalvillas3"]; ?> - Deluxe Studio - Savanna View <BR><?php } ?>
</div>
so'($ x =='N')|| ($ x =='')'? –
变量和'$ _POST'键之间的关系是什么,例如'$ animalvillas1'和'$ _POST [“animalvillas1”]'? –
感谢您的回复,我编辑了OP以包含index.html – plzdonthackme