我有一个表单,如果他们有代理,他们选择按钮,多个输入框使用 JQuery 中的 SlideDown() 向下滑动。添加并提交文本后,值将存储为会话,如果有错误,则用户将被发送回表单页面并必须进行更正。现在我有了它,如果将分配给相应框的值发回,输入框将向下滑动。但是这些值没有显示出来,你看不到它们,如果你点击一个,你会看到光标在哪里,你可以知道这些值在那里。
输入段代码:
<div class="agensele"> Do you have an agent? <input type="submit" value="Yes" name="agentsele" class="agentsele"/></div><!----- END .InputInner ---------->
<input type="hidden" value="" name="hiddenagentsele" />
<div class="noagensele"> Do you have an agent? <input type="submit" value="No" name="noagentsele" class="noagentsele"/> </div><!----- END .InputInner ---------->
<input type="hidden" value="" name="hiddennoagentsele" />
</div><!---------------------------------END .InputContaienr ----------------------------------->
<script>
$(".agentsele").click(function () {
return false;
});
$(".agentsele").click(function () {
$('input[name=hiddenagentsele]').val("clicked");
$('input[name=hiddennoagentsele]').val("unclicked");
});
$(".noagentsele").click(function () {
return false;
});
$(".noagentsele").click(function () {
$('input[name=hiddennoagentsele]').val("clicked");
$('input[name=hiddenagentsele]').val("unclicked");
});
</script>
<br>
<div class="InputContainer">
<span class="agent">Agent Name: </span><div class="InputInner"> <input type="text" name="agentname" class="agentinput" value="<?php echo $_SESSION['agentname']; ?>"></div><!----- END .InputInner ---------->
<?php
$setError=$_GET['seterror'];
if($setError == 1){
if (!isset($_SESSION['agentname']) && (isset($_SESSION['yesele']))){
echo "<span style='color:red;' class='errorMsg'>*Required</span>";
}
}
?>
</div><!---------------------------------END .InputContaienr ----------------------------------->
<div class="InputContainer">
<span class="agent">Agent Phone Number: </span><div class="InputInner"> <input type="text" name="agentphone" class="agentinput" value="<?php echo $_SESSION['agentphone']; ?>"></div><!----- END .InputInner ---------->
<?php
$setError=$_GET['seterror'];
if($setError == 1){
if (!isset($_SESSION['agentphone']) && (isset($_SESSION['yesele']))){
echo "<span style='color:red;' class='errorMsg'>*Required</span>";
}
}
?>
</div><!---------------------------------END .InputContaienr ----------------------------------->
<div class="InputContainer">
<span class="agent">Agent's Email: </span><div class="InputInner"> <input type="text" name="agentemail" class="agentinput" value="<?php echo $_SESSION['agentemail']; ?>" ></div><!----- END .InputInner ---------->
<?php
$setError=$_GET['seterror'];
if($setError == 1){
if (!isset($_SESSION['agentemail']) && (isset($_SESSION['yesele'])) ){
echo "<span style='color:red;' class='errorMsg'>*Required</span>";
}
}
?>
</div><!---------------------------------END .InputContaienr ----------------------------------->
<div class="InputContainer">
<span class="agent">Confirm Agent's Email: </span><div class="InputInner"> <input type="text" name="agentemailone" class="agentinput" value="<?php echo $_SESSION['agentemail']; ?>" ></div><!----- END .InputInner ---------->
<?php
$setError=$_GET['seterror'];
if ($setError == 2){
echo "<div style='color:red;' class='errorMsg'> Your Agent Emails Did Not Match</div>";
}
?>
</div><!---------------------------------END .InputContaienr ----------------------------------->
<script type='text/javascript'>
function analyzeagentsection() {
$(".agentinput").slideDown(1000, function() {});
$(".agent").slideDown(1000, function() {});
$(".agentsele").css("visibility", "hidden");
$(".agensele").css("visibility", "hidden");
$(".noagentsele").css("visibility", "visible");
$(".noagensele").css("visibility", "visible");
$(".agentinput").css("visibility", "visible");
}
</script>
<?php
if ($_SESSION['yesele'] == 'yes'){
echo '<script type="text/javascript">'
, 'analyzeagentsection();'
,'</script>';
}
?>
<script>
$(".agentsele").click(function () {
//dropdown.bind('change', function(){
$(".agentinput").slideDown(1000,function(){
});
$(".agent").slideDown(1000,function(){
});
$(".agentsele").css("visibility", "hidden");
$(".agensele").css("visibility", "hidden");
$(".noagentsele").css("visibility", "visible");
$(".noagensele").css("visibility", "visible");
$(".agentinput").css("visibility", "visible");
});
$(".noagentsele").click(function () {
//dropdown.bind('change', function(){
$(".agentinput").slideUp(1000,function(){
});
$(".agent").slideUp(1000,function(){
});
$(".agentsele").css("visibility", "visible");
$(".agensele").css("visibility", "visible");
$(".noagentsele").css("visibility", "hidden");
$(".noagensele").css("visibility", "hidden");
$(".agentinput").css("visibility", "hidden");
});
</script>
CSS代码:
.agent {
display: none;
float: left;
width: 100%;
margin-bottom: 1%;
}
.agentinput {
display:none; width:100%; float:left; /*height:auto;*/
}
.noagentsele {
visibility:hidden;
}
.noagensele{
visibility:hidden;
display: block;
}
.agentsele {
}
.agensele{
display: block;
}