Clear value from form field

Hello all

I have a function that shows/hides divs on my page.


function hidediv() {
   var div_num = $("#myformvalue").val();
   if (div_num == 1) {
   $("#mydiv").hide(); 
	};


}

I would like to add a feature to this code. Basically if a div is hidden then I want the form values within that div to be wiped.

Ideally it would look something like this:


function hidediv() {
   var div_num = $("#myformvalue").val();
   if (div_num == 1) {
   $("#mydiv").hide();
  [B]AND ThisValue = ""[/B]
	};


}

Is it this simple to do? Thanks.

Also to the admin, the site is looking slick. Like it a lot.

jQuery has a selector for all form fields, called ‘:input’, so you can use that to clear all of the form fields that are within the context of the div, with:


$(':input', '#mydiv').each(function () {
    this.value = '';
});

thanks for that. let me give it a go

that works perfectly thanks a lot paul as always.