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
https://forums.phpfreaks.com/topic/134028-solved-comparison-problem/
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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.