Page 1 of 1

Showing both messages on when document is ready

Posted: Tue Nov 23, 2010 2:58 pm
by CoolAsCarlito
I apologize now for putting non php code inside of php tags but don't see where regular code can get bracketed. Anyway when I have this form loading its loading both messages when I told it to hide it and don't know why. Does anyone else? I looked inside the source code of the form and it's not saying the jquery function is involved.

Code: Select all

<script type="text/javascript">
    $(document).ready(function() {
    $('div.message message-error').hide();
    $('div.message message-success').hide();
    $("input.submit").click(function() {
        $('div.message message-error').hide();
        var divisionname = $("input#divisionname").val();
  		if (divisionname == "") {
        $("div.message message-error").show();
        $("input#name").focus();
        return false;
      } 
        var dataString = 'divisionname='+ divisioname;
        $.ajax({
        type: "POST",
        url: "bin/process.php",
        data: dataString,
        success: function() {
        $("div.message message-success").show();
        return true;
    }
  });
  return false;    
    });
  });
  
</script>
<!-- Form -->
				<form action="" name="divisionform">
					<fieldset>
						<legend>Add New Division</legend>

						<div class="field required">
							<label for="divisionname">Division Name</label>
							<input type="text" class="text" name="divisionname" id="divisionname" title="Division Name"/>
							<span class="required-icon tooltip" id="" title="Required field - This field is required, it cannot be blank, and must contain something that is different from emptyness in order to be filled in. ">Required</span>
						</div>
                        	<input type="submit" class="submit" name="submitdivision" id="submitdivision" title="Submit Division" value="Submit Division"/>
					</fieldset>
				</form>
                <div class="message message-error">
					<h6>Required field missing</h6>
					<p>Please fill in all required fields. </p>
				</div>
                <div class="message message-success">
					<h6>Operation succesful</h6>
					<p>Everything's going according to plan.</p>
				</div>
<!-- /Form -->

Re: Showing both messages on when document is ready

Posted: Tue Nov 23, 2010 4:12 pm
by CoolAsCarlito
Issue has been fixed.

Re: Showing both messages on when document is ready

Posted: Tue Nov 23, 2010 4:26 pm
by pickle
FYI - the "PHP Code" button is just a shortcut to regular syntax highlighting.

You can post HTML code: [ syntax=html ][ /syntax ],
Javascript: [ syntax=javascript ][ /syntax ]
CSS: [ syntax=css ][ /syntax ]
(spaces added so the tags would show up)

And pretty much any other language you'll encounter when doing web development.

Re: Showing both messages on when document is ready

Posted: Tue Nov 23, 2010 4:44 pm
by CoolAsCarlito
Thank you for the added info.