Alert Messages + Counters
Dec 14, 2005
I was wondering if it was possible to have a variable count down in a
window.confirm dialog box. Like the type of message some systems have
to log users out automatically.
E.g "You will be logged out in x seconds. Do you want to stay logged
in. Yes No"
where the x value would count down and if they didn't press yes then
they would be redirected to another page to log then out.
View 8 Replies
ADVERTISEMENT
Aug 25, 2004
I have been looking for a way to give something back to this forum as it has helped me greatly, and I am hoping that this might be of value to someone.
Basically I was just tired of consistantly commenting and uncommenting out alerts in my code so I wrote some code that would allow me to keep my alerts and only show them when I wanted to, and only the types of alerts I wanted to show.
I thought that using bitwise operators would give me the flexibility to specify different options and a quick way of finding out what options were wanted. There are other ways of doing this of course, and this is one approach.
The bitwise OR operator "|" says if one of the two vars has the bit set, then set the bit.
the bitwise AND operator "&" says if both of the two vars has the bit set, then set the bit.
It starts with my bitwise values:
var NONE = new Number(0);// 00000000
var ALL = new Number(1);// 00000001
var INFO = new Number(2);// 00000010
var LOCAL = new Number(4);// 00000100
var PARAM = new Number(8);// 00001000
var COUNT = new Number(16);// 00010000
These values are really important. Earlier I used 0 through 5 and because of the way bitwise operations work, COUNT was equivelant to ALL and PARAM. what you are doing is blending bits and then getting a value. So, in the 0 through 5 approach, COUNT was 00000101 (5). When I OR'd ALL with PARAM I got 00000101 which was a result of 00000001 with 00000100 (4)! So be really careful if you go this route to double check that no combination of vars will equal other vars.
In our constructor we get the value thus:
function FormCheckBase( objForm, blnStateIsDebug, sCulture )
{
this.Form= eval('document.' + objForm);
this.Debug= new Number( blnStateIsDebug );
this.Culture= new String( sCulture );
}
with this call:
objFrm = new FormCheck( 'FormName', INFO | LOCAL | PARAM, sCulture );
Then in the instance methods of the FormCheck class, I wrap my alert boxes.
if ( this.ShowErrorAlert( this.PARAM ) ) // or whatever other value you want.
{
alert( sWhoAmI + "iArrayLength: " + iArrayLength );
alert( sWhoAmI + "blnBlank: " + blnBlank );
}
ShowErrorAlert does a bitwise "AND" to see if we have a match. We are also testing for ALL, and if that is passed originally, we are returning a true to show the alert.
FormCheckBase.prototype.ShowErrorAlert = function( iAlertBit )
{
var bitCompareResult = new Number(0);
var showMe = new Boolean(false);
bitCompareResult = (this.Debug & this.ALL);
showMe = ((bitCompareResult == this.ALL) ? true : false );
alert( showMe );
if ( showMe == true )
return showMe;
bitCompareResult = (this.Debug & iAlertBit);
showMe = ((bitCompareResult == iAlertBit) ? true : false );
return showMe;
};
I also did a couple of helper functions that would change the Debug var before I went into a method and reset it after I was done. Sometimes you might not want every single method to start showing alert boxes. So I did a SetDebugBits that sets the value of Debug and GetDebugBits that gets the current value of Debug. Call GetDebugBits first to store the current value, then call SetDebugBits to set it to whatever you want to use, and then make another call to SetDebugBits with the original value to set it back.
We mostly call our FormCheck constructor with the value of NONE, and then work on a method by method basis as we have lots of methods in the class.
View 7 Replies
View Related
May 13, 2011
so here is my "Project" for this class
[URL]
and here are the directions where im stuck at, just right click view source to see the code. I believe what i am doing wrong is where i enter my variables and i dont know how to get an alert message to pop up using an if statement as well as getting the values for the distances to show up correctly
directions:
8. Now we will write some JavaScript to validate the input. We don’t want the user to be able to enter the same origin and destination city when they book a ticket. So we will use an if statement to check that. If they have entered the same origin and destination city then we will tell them that by using an alert statement and make them select again. All of your code to validate the input code goes in between the single quotes of the onClick event in the Calculate Fare button. Follow these steps: a) Assign the value of the origin city to a variable called origin Note that the value that gets assigned to origin is actually 0, 60, 90, 120 or 150 (and NOT Bellingham, Everett, Seattle etc.) since the value we gave to the each element of the list was its distance from Bellingham. This will make our lives easier later when we compute the fare. b) Assign the value of the destination city to a variable called destination in a similar fashion. c) Write an if statement that will test whether origin is equal to destination and if it is then do two things. i. Issue an alert message that says input different origin and destination cities ii. Stop the execution of the JavaScript code in the onClick event. Use return; as the second statement inside the if statement. Remember to use curly braces to denote that two statements are contained within the if statement. Your if statement will have the following structure to it.
if (<put the test you want to do here>)
{
alert(<put the message here>);
return;
View 2 Replies
View Related
Nov 21, 2011
I am looking for a multiple countup or age timer within a html page (using javascript). I want to display below each child picture the age clock/counter of the child. I do not know javascript well (I recognize some code) and know a little of html. I have searched on internet and nothing seems to get close to the below functionality. There are plenty of countup counters etc, but mostly count days, and those that do count age are single use only. Below is some code my friend found. That code works for one person/age only and includes weeks. The thing is that I want one page with all the children listed.
Example of Expected Outcome:
Picture John born in Thailand
John is 10 years, 03 months, 16 days, 12 hours, 14 minutes, 03 seconds old.
Picture Mary born in Florida, USA
Mary is 08 months, 12 days, 14 hours, 02 minutes, 53 seconds old.
Picture Chris born in Melbourne, Australia
Chris is 04 years, 02 months, 03 days, 01 hours, 06 minutes, 12 seconds old.
Picture Lindy born in The Netherlands
Lindy is 03 years, 11 months, 24 days, 23 hours, 44 minutes, 23 seconds old.
And the clocks keep ticking and counting up. Please note that since Mary is less than a year old, the 0 year value does not show. I also would like the possibility to consider the time differences between the places they were born and the time zone the web page viewer is in. Is that possible? Or maybe I have to recalculate their GMT (Greenwhich time zone) birth time for that to work, or maybe the time zone of the server? How can we make that accurate?
The hours, minutes, and seconds, would be great, but is of course optional. The code below also shows weeks, which is up to you to use or not. Maybe the script can allow you to choose which values to show? I would like this for at least four children, but the possibility to add more later by copying some code would be great. This is not an online form, so all time/date of birth details can be set in the script.
Here is the script I found:
<!-- Copy and Paste into HEAD of HTML-->
<SCRIPT type="text/javascript" language="JavaScript">
function ElapsedTime(inFromDate,inToDate) {
var inFromDate = (arguments.length == 0) ? new Date() : arguments[0];
var inToDate = (arguments.length == 1) ? new Date() : arguments[1];
// if (arguments.length == 0) var inFromDate = new Date(); // IE4 has a bug in constructors,
// if (arguments.length == 1) var inToDate = new Date(); // so use above method.
var fromDate = new Date(inFromDate);
var toDate = new Date(inToDate); .....
View 2 Replies
View Related
Jan 13, 2011
There are lots of javascript textarea counters/limiters out there but what I need is a counter that counts and displays the number of characters being typed, the current page number (i.e. say 160 characters make a page), and probably the number of characters left per page. No limit to number of characters typed, just count characters and pages and displays them.
View 4 Replies
View Related
Oct 21, 2011
heres my code:
Code:
<script language="JavaScript">
var checkobj
function agreesubmit(el){[code]....
i need to make it like if the button is clicked and there the agreement checkbox is not checked.. it should give an alert that the alert is not checked.. i know that would require a if and else statement but i cant figure out how to do it
View 3 Replies
View Related
Nov 13, 2010
i am facing a problem after using jquery jconfirm alert. Issue is that after receiving confirm alert, when user press tab to go on Cancel button and press Enter key there, despite of firing event of Cancel button, it fires the event of OK button. this issue is not produced when user press the cancel button by mouse. Waiting for your replies.
View 1 Replies
View Related
Feb 16, 2011
I am trying to throw an alert with the attributes of a submit button in the alert.
What am I doing wrong?
View 4 Replies
View Related
Jul 23, 2005
I need to translate the messages of mine scripts, as I can make
professionally this working with the pair php and javascript?
View 5 Replies
View Related
Mar 4, 2010
I'm finding (like small syntax errors) in my JS/html which are sometimes hard to spot straight away. For example, when coding python on the web, I usually use try: except: and then use the error function to output what went wrong on the webpage.
View 3 Replies
View Related
Jul 4, 2011
IE browser (even IE8) is giving warning when I open a webpage with JavaScript in it. I can of course close the warning but since I am developing webpages that will be deployed and used by customers, customers will get the warning messages too. How do I design webpage that don't popup ActiveX warning message on customer browser when they open pages with JS in it?
View 4 Replies
View Related
Oct 5, 2009
how can I make it hold only X amount of messages then after X amount of messages it just removes the last one.This isn't all the code but I figure it has to be something within this code that I have to change. If you want to look at the source code to go [URL] and take a look there.
//Function for initializating the page.
function startChat() {
//Start Recieving Messages.
[code]....
View 3 Replies
View Related
Feb 25, 2006
but i need one to display 1 text massage of, lets say, 5 whole messages, randomized.
View 1 Replies
View Related
Aug 31, 2006
I'm trying to make a prompt where if a person types in their username, according to the name it will play a hello message with their name and have their own background.
The script so far looks like this, but I'm trying to make it work.
<script language="JavaScript">
name=prompt("Please Enter Your Name"");
if (name == "Ex1")
{
document.write("<html><head><title>Welcome " + name + "</title></head><body><EMBED src="sound1.ram"><h1>Hello, " + name + "</body></html>");
}
if (name == "Ex2")
{
document.write("<html><head><title>Welcome " + name + "</title></head><body><EMBED src="sound2.ram"><h1>Hello, " + name + "</body></html>");
}
if (name == "Ex3")
{
document.write("<html><head><title>Welcome " + name + "</title></head><body><EMBED src="sound2.ram"><h1>Hello, " + name + "</body></html>");
}
//etc
}
</script>
View 2 Replies
View Related
Oct 27, 2010
'Error On Page' messages, IE only.. I need badly to get rid of these error messages. i'm showing my sites to potential employers. When clicking on the ! icon, the so-called 'Details Page' is too cryptic to be of help usually. the line numbers do not correspond to the JS's line numbers (i'm using BBEdit).
View 4 Replies
View Related
Jan 21, 2010
I am trying to fadeIn error message received from the server.Here is the code:$("#" + RowID + "> TD:nth-child(4)").append("<err class='error'>" + err.Message + "</err>").fadeIn(1000);But the fadeIn() does not seem to work, it shows the message straight away ..off courseI am missingsomethinghere, probably the append() and fadeIn() do not go hand in hand.
View 3 Replies
View Related
May 3, 2009
Is it possible to disable showing error messages in jquery.validate plugin at all?
I just need to aply css error class, not to see error messages anywhere.
View 4 Replies
View Related
Nov 23, 2010
When I have this form loading its loading both messages when I told it to hide it and don't know why. I looked inside the source code of the form and it's not saying the jquery function is involved.
Code:
<script type="text/javascript">
$(document).ready(function() {
$('div.message message-error').hide();
$('div.message message-success').hide();
$("input.submit").click(function() {
$('div.message message-error').hide();
var divisionname = $("input#divisionname").val();
if (divisionname == "") {
$("div.message message-error").show();
$("input#name").focus();
return false;
} .....
View 2 Replies
View Related
Feb 13, 2011
What can I do to find out what the errors in the error console mean?
View 7 Replies
View Related
Jul 30, 2010
I have 2 java Servlet files EmpRecord & Delete. Employee has a button of delete, on clicking it....page will be redirected to Delete.java Here the record will be deleted. Now, I want to redirect Delete.java back to EmpRecord.java where the message "Record deleted" will be displayed. How can I pass the message from Delete.java to EmpRecord.java to display the message?
View 2 Replies
View Related
Feb 20, 2010
Looking to have a div on my page that will give the user some tips or help for that specific page.There should be a "dont show me again button" so the div will dissapear and the user wont see it again..What is the best way to approach this?Ajax calls, cookies, session variables, storing info in mysql?. Im developing in PHPIve heard a lot of different ways but looking for the best way..
View 2 Replies
View Related
Jul 8, 2005
What is the simplest/easiest way to display messages from another
script without refreshing the browser.
I have a server side script that dumps messages like.
server_received.php
<?php
...
echo "received fn123.tar";
...
echo "moved fn123.tar"
...
echo "received fn567.tar";
?>
I can dump the above messages into a file if necessary so
many clients can read it. Want a client like below
client_viewer.php
I want to display the above messages at the bottom of many other
other pages at the bottom as I receive the files.
View 15 Replies
View Related
Sep 24, 2008
I'm using validation plug-in in our application for customers fromRussia. I need to set russian messages for all customers from allplaces in the world. How can i do that? Messages are in "localzation/
View 5 Replies
View Related
Jul 21, 2011
I'm new to using jquery and I have a question regarding the validate plugin. How can I make the error messages appear where I want them? Right now they appear to the right of the input field but I'd like them to appear below it or wherever i'd like
View 1 Replies
View Related
Feb 18, 2010
I want to display validation messages in a callout image like we display msgs in alert box function provided by the javascript. means for eg. if user doesn't enter a value in a field then i want to display msg like 'Field is required' in the popup callout image above the field itself.
View 3 Replies
View Related
Mar 17, 2010
I'm trying to change the default required field message in the validation plugin from "This field is required" to simply "Required". I tried to do so like this:
[Code]...
but this isn't working. I'd prefer not to edit the actual code to change the message, although that is an option (but one that would mean constantly updating the message when the validation code is downloaded once again).
View 5 Replies
View Related