Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    Regular Coder
    Join Date
    Jun 2008
    Posts
    682
    Thanks
    114
    Thanked 2 Times in 2 Posts

    Missing } after property list

    For some reason I run my script and its saying missing } after property list. But I'm not seeing it.

    Code:
    <script type="text/javascript">
        $(document).ready(function() {
            $('div.message-error').hide();
            $('div.message-success').hide();
            $('ul#characterList').css( 'margin-left', '120px' );
            $('li').remove('.characterName');
            $("#handlerForm").validate({ 
                rules: {
                 firstName: "required",
                 lastName: "required",
                 userName: {
                    required: true,
                    minlength: 2
                 },
                 password: {
                    required: true,
                    minlength: 5
                 },
                 password2: {
                 required: true,
                    minlength: 5,
                    equalTo: "#password"
                 },
                 email: {
                    required: true,
                    email: true
                 },
                 messages: {
                     firstName: "Please enter your firstname",
                     lastName: "Please enter your lastname",
                     userName: {
                        required: "Please enter a username",
                        minlength: "Your username must consist of at least 2 characters"
                     },
                     password: {
                        required: "Please provide a password",
                        minlength: "Your password must be at least 5 characters long"
                     },
                     password2: {
                        required: "Please provide a password",
                        minlength: "Your password must be at least 5 characters long",
                        equalTo: "Please enter the same password as above"
                     },
                     email: "Please enter a valid email address"
                 }
            });
            $("input.submit").click(function() {
                var userID = $("input#userID").val();
                var defaultChar = $("select#charactersDrop option:selected").text();
                var userName = $("input#userName").val();
                var firstName = $("input#firstName").val();
                var lastName = $("input#lastName").val(); 
                var email = $("input#email").val(); 
                var statusID = $("select#statusID").val(); 
                var isAdmin = $("select#isAdmin").val(); 
                 var liElements = $("ul#characterList li");
                 var characterIDList = "";
                 for( var i = 0; i < liElements.length; i++ ) {
                    var liElement = $( liElements[ i ] );
                    
                    // only start appending commas in after the first characterID
                    if( i > 0 ) {
            	       characterIDList += ","; 
                    }
            
                    // append the current li element's characterID to the list
                    characterIDList += liElement.data( 'characterID' );
                 }
                 var dataString = 'userID=' + userID + 'userName=' + userName  + '&password=' + password + '&firstName=' + firstName + '&lastName=' + lastName + '&email=' + email + '&statusID=' + statusID + '&isAdmin=' + isAdmin + '&characterIDList=' + characterIDList + '&submitHandler=True';
                 $.ajax({
                     type: "POST",
                     url: "processes/handler.php",
                     data: dataString,
                     success: function(myNewVar) {
                        if (myNewVar == 'good') {
                            $('div.message-error').hide();
                            $("div.message-success").html("<h6>Operation successful</h6><p>" + userName + " saved successfully.</p>");
                            $("div.message-success").show().delay(10000).hide("slow");
                            $(':input','#handlerForm')
                            .not(':submit, :button, :hidden')
                            .val('')
                            $('ul#characterList li').each(function() {
                                $(this).remove();
                            });
                        } else if (myNewVar == 'bad1') {
                            $('div.message-success').hide();
                            $("div.message-error").html("<h6>Operation unsuccessful</h6><p>" + userName + " already exists in the database.</p>");
                            $("div.message-error").show();    
                        } else if (myNewVar == 'bad2') {
                            $('div.message-success').hide();
                            $("div.message-error").html("<h6>Operation unsuccessful</h6><p>" + email + " already exists in the database.</p>");
                            $("div.message-error").show();     
                        } else if (myNewVar == 'bad3') {
                            $('div.message-success').hide();
                            $("div.message-error").html("<h6>Operation unsuccessful</h6><p>" + userName + " and " + email + " already exists in the database.</p>");
                            $("div.message-error").show();     
                        } else if (myNewVar == 'bad1bad2') {
                            $('div.message-success').hide();
                            $("div.message-error").html("<h6>Operation unsuccessful</h6><p>" + userName + " and " + email + " already exists in the database.</p>");
                            $("div.message-error").show();     
                        }  
                    }
                });
                return false;    
            });
        });
        </script>
        
        <!-- Form -->
        <form action="#" id="handlerForm">
        	<fieldset>
        		<legend>Add New Handler</legend>
                <div class="field required">
        			<label for="userName">User Name</label>
        			<input type="text" class="text" name="userName" id="userName" title="User Name"/>
        			<span class="required-icon tooltip" 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>
                <div class="field required">
        			<label for="password">Password</label>
        			<input type="password" class="text" name="password" id="password" title="Password" />
                    <span class="required-icon tooltip" 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>
                <div class="field required">
        			<label for="password2">Confirm Password</label>
        			<input type="password" class="text" name="password2" id="password2" title="Confirm Password" />
                    <span class="required-icon tooltip" 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>
                <div class="field required">
        			<label for="firstName">First Name</label>
        			<input type="text" class="text" name="firstName" id="firstName" title="First Name"/>
                    <span class="required-icon tooltip" 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>
                <div class="field required">
        			<label for="lastName">Last Name</label>
        			<input type="text" class="text" name="lastName" id="lastName" title="Last Name"/>
                    <span class="required-icon tooltip" 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>
                <div class="field required">
        			<label for="email">Email</label>
        			<input type="text" class="text" name="email" id="email" title="Email"/>
                    <span class="required-icon tooltip" 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>
                <div class="field required">
        			<label for="statusID">Status</label>
                    <select class="dropdown" name="statusID" id="statusID" title="Status">
                    <option value="0">- Select -</option>
                    <?php
                    $query = 'SELECT ID, statusName FROM statuses';
                    $result = mysqli_query ( $dbc, $query ); // Run The Query
                    while ( $row = mysqli_fetch_array ( $result, MYSQL_ASSOC ) ) { 
                        print "<option value=\"".$row['ID']."\">".$row['statusName']."</option>\r";
                    }
                    ?>
                    </select>
        			<span class="required-icon tooltip" 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>
                <div class="field required">
        			<label for="isAdmin">Administrator</label>
                    <select class="dropdown" name="isAdmin" id="isAdmin" title="Administrator">
                    <option value="0">- Select -</option>
                    <?php
                        $administrator = array('Yes', 'No');
                        foreach($administrator as $admin):
                    ?>        
                    <option value="<?php echo $admin; ?>"><?php echo $admin; ?></option>
                 
                 <?php endforeach; ?>
                    </select>
        			<span class="required-icon tooltip" 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>
        	</fieldset>
            <fieldset>
        		<legend>Handler's Characters</legend>
                <div class="field">
        			<label for="charactersDrop">Characters</label>
                    <select class="dropdown" name="charactersDrop" id="charactersDrop" title="Characters Dropdown">
                    <option value="0">- Select -</option>
                    <?php
                    $query = 'SELECT ID, characterName FROM characters WHERE ID NOT IN (SELECT characterID FROM handlerCharacters) ORDER BY `characterName`';
                    $result = mysqli_query ( $dbc, $query ); // Run The Query
                    while ( $row = mysqli_fetch_array ( $result, MYSQL_ASSOC ) ) { 
                        print "<option value=\"".$row['ID']."\">".$row['characterName']."</option>\r";
                    }
                    ?>
                    </select>
                    <input type="button" value="Add Character" class="" onclick="HandlerCharacters()"/>
                    <ul id="characterList"></ul>
                </div>
                    <input type="hidden" name="userID" id="userID" value="<?php echo $userID; ?>" />      
                    <input type="submit" class="submit" name="submitHandler" id="submitHandler" title="Submit Handler" value="Submit Handler" />
        	</fieldset>
        </form>
        <!-- /Form -->
        <!-- Messages -->
        <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>Handler was added to the database.</p>
        </div>
        <!-- /Messages -->
        
        <script type="text/javascript" language="javascript">
        // Long version
        function HandlerCharacters() {
            function isDupe(which) {
                var result = false;
                $('ul#characterList li').each(function(i, e) {
                    if ($(e).data('characterID') == which) {
                        result = true;
                        return false; // break out of .each()
                    }
                });
                return result;
            }
            var characterID = $('#charactersDrop option:selected').val();
            var characterName = $('#charactersDrop option:selected').text();
            if (characterID > 0 && !isDupe(characterID)) {
            	// Create the anchor element
            	var anchor = $( '<a href="#">Remove</a>' );  
            	
            	// Create a click handler for the anchor element
            	anchor.click( function() {
            		$( this ).parent().remove();
            		return false;  // makes the href in the anchor tag ignored
            	} );
            	
            	// Create the <li> element with its text, and then append the anchor inside it.
            	var li = $( '<li>' + characterName + '&nbsp;</li>' ).append( anchor );
            	li.data( 'characterID', characterID );
            	
            	// Append the new <li> element to the <ul> element
            	$( '#characterList' ).append( li );
            }
        }
        </script>
    Last edited by CoolAsCarlito; 03-06-2011 at 08:10 PM.


 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •