2012-09-27 114 views
0

我有一個表單,如果他們有一個代理,他們選擇按鈕多個輸入框在JQuery中使用SlideDown()滑動。一旦添加並提交了文本,這些值就會以會話的形式存儲起來,如果某些內容不正確,那麼用戶將被髮回到表單頁面並且必須更正。現在我已經將輸入框向下滑動,如果用指定給相應框的值發回。但值不顯示,你看不到它們,如果你點擊一個,你會看到光標在哪裏,你可以告訴值在那裏。輸入框文本在使用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; 
} 
+0

當頁面加載時,您的類agentinput最初不顯示,並且在調用analyzeagentsection()函數後顯示block。對? –

+0

如果agentinput類最初顯示阻止,您是否在輸入框中獲得值?問題是,它在最初顯示沒有時不顯示。對? –

+0

我實際上已經修好它了! –

回答

0

其實我剛纔提出的JavaScript檢查,如果是的話就只是改變框可見的值。

代碼:

<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> 

感謝你們的辛勤工作!

相關問題