jquery reset form help

hello
i am trying to find a way to reset a div in a form. the div is #message and the code i am using at the moment is clearing the fields but not the message. if someone could show me how to do this i would be grateful as i need to find a solution quickly. many thanks
JQUERY CODE
===============================

// Feedback form

jQuery(document).ready( function() {

  $("#form").hide();

});

			
  function feedbacknew() 
{    
	$("#form").dialog(
	{
	    autoOpen: false,
	    resizable: false,
	    modal: true,
		show: 'slide',
	    title: 'Submit a feedback request',
	    width: 460,
	    height: 490    		
	});
	
	$('#submit').click(function () 
	{
	    
	    var name = $('.uname').val();
		var email = $('.email').val();
		var position = $('.position').val();
		var feedback = $('.feedback').val();
	    var data = 'uname=' + name+email+position+feedback;
	    $.ajax(
	    {
		type: "POST",
		url: "feedback.php",
		data: data,
		success: function (data) {
			$("#feedback").get(0).reset();
			$('#message').html(data);
			$("#flex1").flexReload();
				
		    
		} 
	    });
	    return false;
		
	});
        
	$("#form").dialog('open');
	
}

HTML FORM
================================================

// Feedback form
<div id="form" style="display:none;">
  <form method="post" id="feedback" class="webform" name="feedback">
    
		
		<label for="company">Company</label>
		<select name="company">
		  <option SELECTED VALUE="">Select an option</option>
		  <option value="Technical">Technical</option>
		  <option value="Database">Database</option>
		  <option value="Error">Error</option>
		  <option value="Other">Other</option>
		</select>
		<label for="name">Full Name:</label>
		<input id="uname" name="uname"  type="text" class="text ui-widget-content ui-corner-all inputbox uname" value="<?php echo $_SESSION['kt_name_usr']; ?>" />
		<label for="email">Email address:</label>
		<input id="email" name="email" type="text" class="text ui-widget-content ui-corner-all inputbox email" value="<?php echo $_SESSION['kt_email_usr']; ?>"/>
		<label for="position">Position:</label>
		<input id="Position" name="Position" type="text" class="text ui-widget-content ui-corner-all inputbox position" />
		<label for="Feedback">Feedback:</label>
		<textarea name="Feedback" cols="25" rows="3" type="text" class="text ui-widget-content ui-corner-all inputbox feedback" />Please make sure that any error messages or numbers are listed here.</textarea><br />
	
   	 	<button id="submit" class="submit">Submit</button>
		<div id="message"></div>
  </form>
</div>

Open in new window

peter_coopAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gurvinder Pal SinghCommented:
so, you are trying to say that this line
$('#message').html(data);

is not setting the data correctly to the div with id message?

can you alert the message to see what is response coming?
0
peter_coopAuthor Commented:
@gurvinder372
hello. the message is appearing ok but when i close the form the message is still there when i reopen. i need a way to reset the #message when the form closes. thanks
0
Gurvinder Pal SinghCommented:
how do you close the form?
0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

peter_coopAuthor Commented:
by clicking the X in the top right part of the dialog window. thanks
0
Gurvinder Pal SinghCommented:
you need to capture onbeforeclose and clear that div
http://docs.jquery.com/UI/Dialog#event-beforeClose

$("#message").html("");
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
peter_coopAuthor Commented:
how that relate to my code please. thanks
0
Gurvinder Pal SinghCommented:
apparently you are using the jquery modal dialog plugin, and no where do i see that you are capturing the click on that close button at the right top. You have to capture that event to clear the message
0
peter_coopAuthor Commented:
i am new to jquery and would be grateful if you could help with this? i would be willing to raise the points. thanks
0
Gurvinder Pal SinghCommented:
all you have to do is check the example in the link that i shared
0
peter_coopAuthor Commented:
i did that bit do not understand it. for example, from the code

$( ".selector" ).dialog({
   beforeClose: function(event, ui) { ... }
});

what is event, ui and what goes in between {...}? thanks
0
peter_coopAuthor Commented:
got it. so you use like this:

beforeclose: function(event, ui) { $("#message").html(""); }
0
peter_coopAuthor Commented:
thank you
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.