IF Statement?
Jul 23, 2007
I have several text fields on page that I would like to make calculations based on if there is a number input in one of the fields.
So, if the price field is populated, the sale price field would populate using a function to do the calculation.
Now, how do I write the code for this to occur? I know how to get the function to fire based on clicking a submit button, but not sure how to do it simply based on a number keyed into the one field. Is this possible and if so, how?
View 4 Replies
ADVERTISEMENT
Apr 4, 2011
my webstie allows users to change the color of the background, so to keep the text readable I have it changing as well.the color picker I am using has text boxes with rgb values 0-255 for each.I am trying to get one bit of text to alternate between red and blue with the conditions
Code:
if(blue>green && blue>red)
{
[code]....
View 2 Replies
View Related
May 12, 2007
I am reading the ECMAScript specs trying to figure out if the next
line is a legal statement or not new Foo();
I think the above code may only be legal as an expression and not as a
stand alone statement. Would this make the above a bug?
Douglas Crockford's JSLint will choke on the above line of code and
stop parsing. All the browsers seem to accept it as ok and work as I
expect: the returned object just doesn't get assigned to anything.
The time I have used a line like the above is when the constructor has
side effects and the "class" keeps track of all its instances.
Any ideas what is right or wrong in this case?
View 2 Replies
View Related
Jul 23, 2005
What is the correct construct for accessing "pageYOffset" in another window?
I've tried this, but it doesn't work:
var mainPageYOffset;
//
mainPageYOffset = parent.main.window.pageYOffset;
View 2 Replies
View Related
Aug 3, 2007
It's been a while since I've worked with javascript time comparison,
and I was wondering how I can say "if time < 15:30"?
The semicolon looks out of place to me, and indeed it has caused an
error.
View 7 Replies
View Related
Jul 20, 2005
I remember using if statements with null in it. For example, at one
point I used this:
if (value == null) {
value = "something";
}
document.write(value)
However, this script causes an error in any browser. Why can't it
correct the value like it should?
View 1 Replies
View Related
Jul 13, 2010
For the following two snippets, they can all pass Firefox.However, I would like to know the rule of thumb when I have to use ; to indicate the end of
[Code]...
View 1 Replies
View Related
Nov 14, 2011
I have a two fold question:1) Why would my while statement not be workingI have cleaned up my code a little (although not perfect) but my while statement is not behaving, it does not output any numbers on a console.debug (using google chrome, or any other browser for that matter) which from my understanding it should?and 2) Slightly out of the remit of this forum I suppose, but this code is quite lengthy and I know there are ways to make this more efficient I just dont know what they are?
function generatePurchaseFields(dom) {
new Ajax.Request('/control/?page=tldmaxyears&domain=' + dom, {
method: 'get',
[code]....
View 1 Replies
View Related
Nov 1, 2005
This is my first time using the switch statement. I would appreciate your suggestion on how to do this properly. I am trying to get customer age which is (age) and compare it with the monthly rate then the text msg will display in the textarea. Also, I am having trouble figuring out how I can defined my monthlyRate in the switch or do I need to this outside of the switch? Code:
}
View 10 Replies
View Related
Apr 27, 2006
i have the following:
a1="asdf"
how can i check in an if statement whether contains a numeric only value and if not then alert.
View 6 Replies
View Related
May 16, 2009
What is the purpose of with statement in JS?
View 3 Replies
View Related
Dec 8, 2011
I am trying to test the id of three input boxes so that I can capitalize the first letter.
The fname and lname work fine but mi does nothing and I get no error is this because of the if statement or the fact that the mi only has one character?
View 1 Replies
View Related
Apr 14, 2009
I need to give two separate alerts depending on what the user clicks when they click the "Submit" button. I am using a confirm box. If they click "OK" it thanks them for their order. If they click "Cancel" it should go back to the form. I have written the code that I thought would work but it will not.
function confMsg(){
var s
s = confirm("Click OK to Submit Order. Click Cancel to Cancel")
if (s=="true"){
alert("Thank You for Your Order!")
else
return;
}}
View 2 Replies
View Related
May 26, 2010
I am working on a script that calculates the rental rate for a property. I currently have this code and form, which works as I wish it to.
Code:
<script type="text/javascript">
function roundCents(amount) {
[code]....
View 3 Replies
View Related
Aug 26, 2010
I would like to make the following statement clearner. I'm thinking something like the SQL "variable IN (value1, value2, value2, etc.)" operator.
Code JavaScript:
if((e.which > 47 && e.which < 58) || (e.which > 95 && e.which < 106) || e.which==8 || e.which == 46 || e.which == 37 || e.which == 39 || e.which == 13) return e.which;
View 4 Replies
View Related
Sep 7, 2010
How can I get the result for the following SQL statement using JavaScript?
SELECT branch, region, referral, COUNT(DISTINCT LPS) FROM table GROUP BY branch, region, referral
Data:
BranchClientReferral TypeLPS #
402036402430Psychological File Review30
402036402430Psychological File Review50
[code]...
View 4 Replies
View Related
Mar 3, 2010
document.write("<img src=' "+r_image[rand_int]+" '>");
could it not be just written like this:
document.write("<img src='r_image[rand_int]' />");
View 2 Replies
View Related
Apr 15, 2010
I have an html form that calculates a square footage (length x width)
Code:
<center>
<form name="frmOne">
[code]....
View 7 Replies
View Related
May 3, 2010
a. only logical operators
b. only comparison operators
c. both logical and comparison
d. you cannot use operators with an if statement.
this is from my javascript book review for the chapter.
you can use both right? sounds silly i know but just want to make sure for my test.
View 4 Replies
View Related
Jun 23, 2010
I have the following code
Code:
function hideDisplaySingleSuite(textstring) {
var myclass1 = new RegExp('\b'+textstring+'\b');
//Populate the array with all the page tags
[Code].....
are executed, meaning that first the rows with a class is shown and then they are hidden.
View 8 Replies
View Related
Apr 15, 2011
If it is possible to use a string in an if statement?
For example:
If that is not possible (which is probably not its not working with me) how would i go about displaying that?
View 1 Replies
View Related
Dec 14, 2011
I'm trying to do some error handling similar to:
Code:
try{
undefinedfunction()
[code]....
View 1 Replies
View Related
Mar 28, 2010
so i know how to do it by making one function and designating the image to replace and what to replace it with, like
Code:
function roll_over(img_name, img_src)
{
[code].....
View 9 Replies
View Related
Mar 3, 2006
I am looking at a line of code in javascript that I dont understand...
var ad = n % nn;
What I dont understand is what the % represents as a mathmatical
function in javascript.
View 2 Replies
View Related
Mar 20, 2007
For the first time, I'm attempting to write a small Javascript program
using one on the online reference sites. I need some confirmation as
to the behaviour of the break statement.
In the following code:
for ( row = 0 ; row <= 7 ; row++ ) A <----
{
for ( col = 0 ; col <=7 ; col++ ) B <----
{
if ( check ( row, col ) == "pass" )
break ;
}
}
}
Where will control pass to once the break statement is executed?
Will it continue with the first 'for' statement (A) or the second (B)?
Also my 'check' function needs to pass an indication as to it's
success or failure. It does it by:
return ( "pass" ) ;
Am I doing it correctly?
Any links to useful reference sites would be welcomed.
View 22 Replies
View Related
May 14, 2010
I'm trying to stop my script running if someone mouses over a link with the class .focus.
The code:
$(document).ready(function() {
window.setInterval(function() { //Every 3 seconds do this function
if ("a.focus").mouseover(function() {
//Do nothing
}) else {
$(".list li:nth-child(3)").children().toggleClass('focus'); //Remove class from <li> #3
$(".list li:last").css("height", 0);
$(".list li:last").prependTo(".list").animate({ //Put last <li> to the top of the list and animate the height from 0 to 48
height: 48,
},200, function(){
//Animation Complete
});
$(".list li:nth-child(3)").stop().children().toggleClass('focus'); //Add class to <li> #3
}}, 3000);});
View 2 Replies
View Related