Link to home
Start Free TrialLog in
Avatar of Nico2011
Nico2011Flag for United Kingdom of Great Britain and Northern Ireland

asked on

OnChange Submit Form if value = 1 otherwise don't...

Hello,

My JavaScript is rubbish!

I have the following cod, which is a slider.  I use the same include file on two different pages - one I want to submit the form when the slider is changed, and that works fine, but the other I do not want the slider OnChange to submit the form, and for the user to submit it manually.

This is possibly an easy one for you JS experts - I want the line: document.forms['form1'].submit(); to be ignored if a variable, set in ASP Classic = 1 otherwise do not submit.

Here's my full code (and thanks in advance!):

<script type="text/javascript" charset="utf-8">
jQuery("#Slider2").slider
			(
			{
			from: 0,  
			to: 10000000,  
			heterogeneity: ['25/500000', '50/1000000', '75/5000000'],
			scale: [0, '|', '500k', '|' , '1m', '|', '5m', '|', '+10m'],
			limits: false,
			step: 50000,
                calculate: function( value ){
                    var a;
                    if(value<500000){
                        a=value;}
                    if(value>=500000 && value<1000000){
                        a=100000*(Math.floor(value/100000));}
                    if(value>=1000000 && value<=10000000){
                        a=1000000*(Math.floor(value/1000000));}
                    return (a);
                  },
			dimension: '',
            callback: function(value)
                {
                    jQuery("#sale-slide-min").val(jQuery("#Slider2").slider("calculatedValue").split(";")[0]);
                    jQuery("#sale-slide-max").val(jQuery("#Slider2").slider("calculatedValue").split(";")[1]);
					document.forms['form1'].submit();
                }
			}
			);
			</script>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Rainer Jeschor
Rainer Jeschor
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Nico2011

ASKER

Hi Rainer,

Thanks very much - works perfectly.

Have a good day!