Jump to content

[SOLVED] comparison problem


cleary1981

Recommended Posts

Hi, I am having a problem when comparing two numbers. Basically what I am doing is comparing the value of two variables. If var A is less than var B show an error. Trouble is when var A is 1000 and var b is 200 I get the error message. I think it is only comparing the first 3 digits. Can anyone help. Heres the function.

 

function generate() {
var sub = document.getElementById("selectsub").value;
var mod = document.getElementById("selectmod").value;
var actH = document.getElementById("selectheight").value;
var actW = document.getElementById("selectwidth").value;
var actD = document.getElementById("selectdepth").value;
var minH = document.getElementById("minh").innerHTML;
var minW = document.getElementById("minw").innerHTML;
var minD = document.getElementById("mind").innerHTML;
var label = document.getElementById("modlabel").value;

if (document.form1.modlabel.value.length == 0) {
	alert("You must label the module!");
}
else {
	//alert(actH + minH);
	if ((actH < minH) || (actW < minW) || (actD < minD)) {
		alert("Dimensions are below the minimum for this module!");
		}
		else {
			var url = "create_object.php?sub=" + escape(sub) + "&mod=" + escape(mod) + "&actH=" + escape(actH) + "&actW=" + escape(actW) + "&actD=" + escape(actD) + "&label=" + escape(label) + "&panel=" + escape(panel);
			url = url + "&dummy=" + new Date().getTime();
			request.open("GET", url, true);
			request.onreadystatechange = showObject;
			request.send(null);
		}
	}

}

Link to comment
Share on other sites

Hi, I am having a problem when comparing two numbers. Basically what I am doing is comparing the value of two variables. If var A is less than var B show an error. Trouble is when var A is 1000 and var b is 200 I get the error message. I think it is only comparing the first 3 digits. Can anyone help. Heres the function.

 

function generate() {
var sub = document.getElementById("selectsub").value;
var mod = document.getElementById("selectmod").value;
var actH = document.getElementById("selectheight").value;
var actW = document.getElementById("selectwidth").value;
var actD = document.getElementById("selectdepth").value;
var minH = document.getElementById("minh").innerHTML;
var minW = document.getElementById("minw").innerHTML;
var minD = document.getElementById("mind").innerHTML;
var label = document.getElementById("modlabel").value;

if (document.form1.modlabel.value.length == 0) {
	alert("You must label the module!");
}
else {
	//alert(actH + minH);
	if ((actH < minH) || (actW < minW) || (actD < minD)) {
		alert("Dimensions are below the minimum for this module!");
		}
		else {
			var url = "create_object.php?sub=" + escape(sub) + "&mod=" + escape(mod) + "&actH=" + escape(actH) + "&actW=" + escape(actW) + "&actD=" + escape(actD) + "&label=" + escape(label) + "&panel=" + escape(panel);
			url = url + "&dummy=" + new Date().getTime();
			request.open("GET", url, true);
			request.onreadystatechange = showObject;
			request.send(null);
		}
	}

}

 

Hmm...why are you using innerHTML to retrieve certain values?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.