Comparing 2 Input's
Dec 5, 2006
I'm having trouble comparing 2 input boxes, using getElementById.
I have 81 hidden inputs (id's b0 through b80) and 81 input boxes (id's a0-a80). (Its just sudoku, so theres no security threat with them being viewable in the source)
I'm using this code (ill worry about the for loop later)
var solved = true;
if(document.getElementById(a0).value != document.getElementById(b0).value) {
solved = false
alert("not solved"); // debug
}
But it doesnt seem to be working. Im getting the error a0 is not defined. I know for sure that I have an input box with id=a0.
View 4 Replies
ADVERTISEMENT
Jul 23, 2005
I am currently using a function to validate a form on the client side
(see code below). At the end of the function, I would like it to also
compare a startDate against an endDate to ensure that the endDate is
greater than (comes after) the startDate. The date format I'm using is
MM/DD/YYYY and it's writing to an MS SQL Server 2000 database table
via ASP. Code:
View 2 Replies
View Related
Apr 16, 2007
I have two strings that I need to compare and modify when there is a
matching value in the two. If strA = ??,' then I need to remove
the value ??,' from strB and the new value would be strB =
??,12935'
strA = ??,'
strB = ??,12937,12935' (these could be any values in any order)
I'm not sure where to begin on this.
View 8 Replies
View Related
Jul 20, 2005
I need to check if two hashes are identical.
My thoughts are something like this:
function compareHash(hash1,hash2){
if(hash1.length != hash2.length){return false}
for(var key in hash1){
if(hash1[key] != hash2[key]) return false;
}
return true;
}
Have I missed something, or is there a more direct approach?
View 2 Replies
View Related
Mar 5, 2009
I need to test the contents of three fields to validate which contain text, and based on the results, set additional variables. I'm sure this is falling off the log simple, and I got it to work in PHP, but am having problems getting the syntax correct in Javascript.
In a nutshell, if a front AND a rear msg is entered, the price is $115, else the price is $80. I'm sure there's an easier way to code this than what I've done, but I don't know how to correctly perform several && and || in the same comparison.
Here's the PHP...
function notEmpty(){
var FrontMsgTxtTop = document.getElementById('FrontMsgTxtTop').value;
var FrontMsgTxtBottom = document.getElementById('FrontMsgTxtBottom').value;
var RearMsgTxt = document.getElementById('RearMsgTxt').value;
[Code]....
View 3 Replies
View Related
Nov 4, 2009
i'm looking for a way to check if the name of the page is equal to a link inside the page being checked. for instance:inside the address bar: http://www.mysite.test.html
<body>
<ul>
<li><a href="test.html"></a></li>
[code]....
View 1 Replies
View Related
Dec 9, 2009
I have the following script
function timeDifference(laterdate,earlierdate) {
var difference = laterdate.getTime() - earlierdate.getTime();
var daysDifference = Math.floor(difference/1000/60/60/24);
difference -= daysDifference*1000*60*60*24
document.write('difference = ' + daysDifference + ' day/s ');
}
var laterdate = ?;
var earlierdate = ?;
timeDifference(laterdate,earlierdate);
//--></script>
And would like to insert my datein and dateout values where the ? marks are above in red. I can call these variables into the form on the page using <%=Request("datein")%> but how do I call a variable into the script above?
View 4 Replies
View Related
Jul 31, 2010
I am trouble in comparing decimal number.
var1 = 0.25
var2 = 0.50
if (var1<var2)
{
alert("Value is less than minimum")
[CODE]....
How can I make it work.
View 3 Replies
View Related
Apr 8, 2011
I am developing a battleship game in javascript. I created a table of grid squares pictures. In the tags in included onclick = "a specific method to place a ship(this.id). This is not working. I am wondering if there is an easier way to pass an id through a parameter or would I have to do something different?
View 1 Replies
View Related
Dec 14, 2007
I have a material table wich contains the article number, a quantity input field, a max quantity field... How can i test that the input quantity is less than the max quant one ?
Here is a sample code :
View 2 Replies
View Related
Jun 4, 2006
I have this function which works great in Firefox, but doesn't work in IE. I can make it work in IE by breaking it in Firefox, but I'd like it to work in both.
Here's the function, with associated code:
function validate_check(input, message)
{
var par = input.parentNode;
var prev = input.previousSibling;
if(!input.checked) {
if(prev.innerHTML != message) {
var errmsg = document.createElement("p");
errmsg.innerHTML = message;
par.insertBefore(errmsg, input);
}
dosubmit = false;
} else if(prev.innerHTML == message) {
par.removeChild(prev);
}}
var agree = document.getElementById('agree');
var agreemsg = 'Please make sure you agree to our <a href="/tou.php" target="_blank">Terms of Use</a> and <a href="/privacy.php" target="_blank">Privacy Policy</a> to add your listing.'
validate_check(agree, agreemsg);
For the two attributes the function accepts, input is a node from that document tree that is a checkbox, and message is a string.
If the checkbox is not checked the function inserts a <p> element immediately before the input. That part works fine in both. However, the 'prev.innerHTML == message' and 'prev.innerHTML != message' don't work properly in IE. I think it is because of the <a> tags in 'message'. However, when I try to use the String() function there are problems because the 'prev' object is not always set, (like, if a paragraph isn't written right before the checkbox).
View 2 Replies
View Related
Jun 13, 2002
I want to put a form on my site where the user can enter some information, but I don't want the user to enter the same information twice over the couple of fields that I have.
Is there a javascript that can help to validate the form information or some other way? And if so, is it easy to do?
View 7 Replies
View Related
Mar 6, 2011
i want an argument that will ask if the previous xmlhttp content was = to the current xmlhttp content. Like as so:
Code:
if(oldxmlhttp = xmlhttp) {
alert("yes");
} else {
[Code]....
All in all i want to make it so it doesn't reload if content is not different. To hold control over the server.
View 3 Replies
View Related
Apr 11, 2010
How do I go about comparing two jquery objects to see if they're actually the same html object.
I've got:
This should add a border to every object in the selected set except for the one defined in someobject... shouldn't it.
View 1 Replies
View Related
Sep 14, 2011
I have a pair of dates in a form that are made up of 3 text fields per date. The day and month fields are 2 digit, the year is 4 digit.
startday
startmonth
startyear
endday
endmonth
endyear
I can't easily change this for a number of reasons. I know the values themselves will be valid (they're generated by a calendar selection script) but I want to check the date created by the end variables is not before the start date. Any script to build a date from the 3 fields for each, and return false if the end date is earlier than the start date?
View 8 Replies
View Related
May 9, 2011
I'm looking to do two things: the first is to move elements of an array to the next index using a function. I have managed to do this like so:
var letters = ['h','i','j','k'];
function moveElements(anArray){
var newArray = anArray;
[code]....
View 6 Replies
View Related
Mar 4, 2010
I have 2 fields in a form, field1 is type hidden while field2 is type text.Both will have numbers in them. I need to compare these 2 in my form validation and having issues getting it to work right. If I do something similar to the following:if ((passForm.field1.value) < (passForm.field2.value) ) {alert.....It runs, but is running the validation, but is reading the values as text and literally left to right.
so for example
If field1 = 12 and field2=3 it does not run the alert (wrong)
If field1 = 12 and field2=100 it runs the alert (wrong)
[code]....
View 2 Replies
View Related
Jun 20, 2011
I'm trying to make my form both check that the e-mail's match and also be case insensitive when being submitted. I've figured out how to get the e-mail's to be checked to match, but can't figure out how to also make it not case sensitive.
This is what I have so far...
<head>
<script type = "text/javascript">
function checkSame() {
var emval1 = document.cform.email.value;
[Code]....
View 5 Replies
View Related
Mar 9, 2010
I am using the following function in order to change an image opacity on a mouseover and mouseout. This function works fine but does not handle a onClick. What I mean by this is...... How can I create/alter the function to handle an onclick? I want to be able to click on an image (one of many) and have that image opacity change to 50%. There are other similar images whose opacity would need to remain at 100%. If one of those are clicked, that images opacity would then change, and the previous would restore to original value of 100% I thought about passing the clicked images id to the function but I can't find a way to compare an image id VS a passed image id.
[Code]...
View 2 Replies
View Related
Apr 10, 2010
This one is throwing me off! Either I am making a stupid mistake or I'm doing it totally wrong I have an array, and I am trying to select unique values from it and assign it to another array. Here is the code:
Code:
var flag;
for (i=0;i<=pdfs.length-1;i++)
{
flag = 1;
for (j=0;j<=pdfs2.length-1;j++)
[Code]...
The problem is that the if (pdfs2[j] == pdfs[i]) statement ends up never being true. There are URL's to pdf files in the array. On the other side, if there is a much easier way to select unique values from an array, please feel free to point it out.
View 2 Replies
View Related
Nov 28, 2005
i am using javascript to compare two strings. it works well with normal strings. but when the strings contain "&" (e.g. & #1234; *no space), it does not work well.
code:
q = document.getElementById("q").value;
a = document.getElementById("a").value;
if (q == a)
document.formName.all("check").innerText = "correct";
else
document.formName.all("check").innerText = "wrong";
anyone have any idea to solve this problem..
View 1 Replies
View Related
Jun 10, 2009
i have a form which has many inputs with the same name and i want to sum all
Code HTML4Strict:
<form name="autoSumForm">
<p>
1<input class="right" type=text name="firstBox[]" value="" onFocus="startCalc();" onBlur="stopCalc();">
101<input class="right" type=text name="firstBox[]" value="" onFocus="startCalc();" onBlur="stopCalc();">
[code]....
View 6 Replies
View Related
Apr 15, 2010
For instance [code]...
But I dont know how to get only the inputs in the div.
View 1 Replies
View Related
Aug 31, 2009
I am trying to write a js that validates a form with two text inputs. The two inputs are: 'D_techA' and 'D_techB'. I just want to add up (sum) the two input fields (which must be positive numbers) and make sure that they add up to exactly 100 (not more and not less). If they do not add up to 100, then an alert should pop up that says "The two values must add up to exactly 100." I have tried and tried to write a js that does this validation (looking at numerous validation scripts posted in this forum and elsewhere) and I just cannot seem to make it work.
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
[Code]...
View 3 Replies
View Related
Apr 11, 2010
I have done lots of looking on the web, but am still unable to figure out why I can not make this simple assignment work.I just need some help with getting something to happen when the user hits submit. What I really want is for a new page to appear with the message using the user inputs, but I would be very happy with just getting the input to appear in the text area that I put in or even for the alert box to pop up with the input. I can work on validation code after I can get some kind of output to work.....
Here is the code I have written:
<html>
<head>
<title>Name and Age</title>
[code]....
View 3 Replies
View Related
Sep 27, 2007
The inputs for the fields of mth6, mth12, mth18, mth24, set50, set75, set 80 and set85.
I would like a way for it to round up to the nearest tenth.
IE:
from 2571 to 2580
from 148 to 150
ect.
any suggestions? Code:
View 5 Replies
View Related