Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6556747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:59:03+00:00 2026-05-25T12:59:03+00:00

I’m using jquery hide, show function in my signup form. By default my div

  • 0

I’m using jquery hide, show function in my signup form. By default my div is hidden as you see from script. Also there are 2 buttons: Submit and Reset. All works well, but there is 1 problem: it doesn’t hide the divs #warr_details1 and #warr_details2 after resetting form. How can i hide them after form reset?

UPDATE

<form id="reg" method="post" action="<?php echo $_SERVER["PHP_SELF"]; ?>">
<fieldset>
<legend>Şirkət Haqqında</legend>
<table>
<tr><td width="270px" align="left">Şirkət: <input  placeholder="Şirkət" type="text" name="company"></td>
<td width="340px" align="right">Ünvanı: <input placeholder="Ünvanı" type="text" name="address"></td></tr>
</table>
</fieldset>
<fieldset>
<legend>Məsul şəxs</legend>
<table>
<tr>
<td width="270px" align="left">Məsul şəxs: <input placeholder="Məsul şəxs" type="text" name="contact_name"></td>
<td width="340px" align="right">Əlaqə telefonu: <input placeholder="Əlaqə telefonu" type="tel" name="contact_phone"></td>
</tr>
</table>
</fieldset>
<fieldset>
<legend>Zəmanət</legend>
<table>
<tr><td rowspan="2">
<label for="warr">Zəmanət</label><input type="radio"  name="warr" value="1">Var 
<input type="radio" name="warr" value="0">Yoxdur
</td>
<td id="warr_details1">Verilmə tarixi (<input id="todayBox" type="checkbox"> Bugün) <input type="text" placeholder="Verilmə tarixi" id="warr_start" name="warr_start"/></td>
<script type="text/javascript">
$("#todayBox").change(function() {
    var dateStr;
    if (this.checked) {
        var now = new Date();
        dateStr = now.getDate() + "." + (now.getMonth() + 1) + "." + now.getFullYear();
    } else {
        dateStr = "";
    }
    $("#warr_start").val(dateStr);
});
</script>
</tr>
<tr id="warr_details2">
<td>Neçə il müddətinə? <input type="number" min="0" name="warr_year"/></td>
</tr>
<script type="text/javascript"/>
$(document).ready(function(){
$("#warr_details1").hide();
$("#warr_details2").hide();

$("input[name='warr']").click(setDisplay);
$("input[type='reset']").click(function() {
    setTimeout(setDisplay, 1);  // setDisplay after the form is reset
});

function setDisplay() {
    var val = $("input[name='warr']").val();
    if (val === '1') {
        $("#warr_details1").show();
        $("#warr_details2").show();
    } else if (val === '0' || val === '') {
        $("#warr_details1").hide();
        $("#warr_details2").hide();
    }
}
});
</script>
</table>
</fieldset>
<table>
<tr>
<td colspan="2" style="text-align:center"><input type="submit" class="button red" name="submit" value="OK" />
<input type="reset" class="button white" value="Təmizlə" /></td>
</tr>
</table>

  </form>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T12:59:04+00:00Added an answer on May 25, 2026 at 12:59 pm

    Put your hiding logic into a common function that you can call from multiple places. Then, call that function from all the places that you want it to be active, including upon a click of the reset button. Now that I can see your HTML, something like this should work:

    $("#warr_details1").hide();
    $("#warr_details2").hide();
    
    $("input[name='warr']").click(setDisplay);
    $("input[type='reset']").click(function() {
        setTimeout(setDisplay, 1);  // setDisplay after the form is reset
    });
    
    function setDisplay() {
        var val = $("input:radio[name=warr]:checked").val();
        if (val === '1') {
            $("#warr_details1").show();
            $("#warr_details2").show();
        } else if (!val || val === '0') {
            $("#warr_details1").hide();
            $("#warr_details2").hide();
        }
    }
    

    And a demonstration: http://jsfiddle.net/jfriend00/5cFCb/.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a text area in my form which accepts all possible characters from
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
Basically, what I'm trying to create is a page of div tags, each has
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I am currently running into a problem where an element is coming back from
We're building an app, our first using Rails 3, and we're having to build

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.