Computing Buttons To Work And Alert Messages?
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
ADVERTISEMENT
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
View Related
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
Dec 9, 2011
What happens is the user selects the number of buttons depending on the number entered in the text box. If the number is 3 in the text box, then the user can only select 3 buttons, if more buttons are selected then it comes with an alert message saying user is beyond limit deselect a button to be able to choose another button.
But these are the problems I have encounted: If I type in "2" in the textbox for example, it allows me to select 2 buttons and comes up with alert if more buttons clicked.
problem 1: but if I change the figure in text box from "2" to "5", then it only allows me to select 3 buttons (I think it is adding 2 from the previous value and 3 to make the current value 5)
problem 2: If I enter a value less than current value, so in this example if I enter in 1 in the textbox which is obviously less than 2, then it lets the user select unlimited number of buttons.
So does anyone know how to fix these problems so that the amount of buttons selected matches correctly to the value in the textbox?
View 1 Replies
View Related
Oct 1, 2010
I can call a rest service I have running in a 'test' environment fine from other tools (or directly in browser for that matter).
When I call using jQuery nothing happens.
No errors, no javascript messages. Nothing. [code]...
View 9 Replies
View Related
Oct 12, 2011
got 3 groups of radio buttons that, if not all checked, needs to give an alert message when button clicked to continue. The button is not a submit button, but just to continue to the next part of the form which is hidden.
<!-- MY RADIO BUTTON GROUPS -->
<input name="id[18]" value="81" id="attrib-18-81" type="radio"><label class="attribsRadioButton zero" for="attrib-18-81"> Kola Cubes</label><br />
<input name="id[18]" value="82" id="attrib-18-82" type="radio"><label
[Code]....
The onClick function on the image is to hide these and display next part of form.
I understand that I could just check them automatically to force user to change them if they wanted to or just continue but if there is way to do it another way.
Or if possible to hide my continue button until all 3 groups are selected, also without using checked="checked"
View 4 Replies
View Related
Sep 22, 2011
so basically this is what I have its 2 sets of radio buttons named budget, premier and superior which values are $2,$3 and $5 respectively. a checkbox that if checked the value would make the the first group of radios multiplied by 2 if not it will remain the same the second group would be weekly, monthly and annually which the values will be multiplied to 1,x(52/12) and 52 respectively to everything above. the total would be displayed as an alert message if the none of the first group is selected an alert would be issued when calculate is pressed and that would be please select level of cover and if none of the second group is selected it would display please select frequency of payment but if none is selected at all both alerts would be displayed on a single dialogue box, i cant make a script to make it function properly .i didnt include the script because i suck it doesnt work
<form name="InsuranceCalc">
<p><h2>calutaling insurance</h2></p>
<p> Please complete the form.</p>[code].............
View 8 Replies
View Related
Jan 14, 2010
Is there a way to create an alert that would pop-u when the user clicked refresh?
On refresh:
"Warning: Refreshing this page will bring you back to the beginning of the application. Are you sure you want to refresh the page?"
Yes - No
On page forward or back:
"Warning: Using the forward/back buttons may cause unexpected problems. Please use the tabs to navigate from page to page. Are you sure you want to use the forward/back button?"
YES - No
View 1 Replies
View Related
May 10, 2011
I'm just learning javascript. I need to create an onclick event for a three-state rollover. I just can't figure out where to place the event. I know it needs to go in my setup rollover function, but can't figure out where to place it so an alert pops up when one of the buttons is clicked. Anyone have any guidance for me? HTML code is (JS is below and button 1 images attached):
[Code]...
View 1 Replies
View Related
Aug 20, 2010
I have a piece of javasacript code that searches through several iframes for buttons with specifi id's. When I find the button, I bind a click event to that button. This works perfectly fine in IE, but only works in Firefox if I alert something. After I click on the alert button ok, the click events are assigned correctly and the buttons work fine. See my code below for achieving this:
$.each(iframe, function(index, ifrm) {
// Add target="_blank" to text hyper links
var hyper = null, hyperCount = 0;
[code]....
View 11 Replies
View Related
Apr 25, 2010
I want to use a button with an onClick(), but I am missing something in the syntax. For testing, I am using the alert() function.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Test</title>
</head>
<body>
[Code]..
View 5 Replies
View Related
Apr 25, 2006
I have this code in actionscript that calls javascript:
actionscript:
zoom_in = function () {
var tw1:Tween = new Tween(mc_1, "_width", Regular.easeOut,
mc_1._width, 0, 1, false); //OK
var tw2:Tween = new Tween(mc_1, "_height", Regular.easeOut,
mc_1._height, 0, 1, false); //OK
ExternalInterface.call("zoom");
}
javascript:
function zoom()
{
top.resizeTo(1024, 768);
self.moveTo(0,0);
}
Everything works perfectly on Firefox 1.5 but not on IE 6+
in IE the "zoom" function doesn't work, but if I add an alert it DOES work:
function zoom()
{
alert('this works');
top.resizeTo(1024, 768);
self.moveTo(0,0);
}
View 1 Replies
View Related
Aug 20, 2011
I am using simpleTreeMenu plugin and it is working fine except for the following. I am building the tree dynamically. If I put in an alert ( //alert("Herem1" + ulidp); )prior to the call of the simpleTreeMenu() function, the page works as expected. It allows me to expand and close the tree, and an alert appears if I pick the selected leafs. But if I take out the alert prior to the call of the simpleTreeMenu() function, the page is not working as expected. The tree hangs, it will not expand once closed. It is like the simpeTreeMenu needs a bit of hang time between the unorderd list (the tree) being built and the invokation of the simpleTreeMenu() function. Does anyone have an idea why this might be the case?
[Code]....
View 3 Replies
View Related
Aug 20, 2010
[code]...
The alert is blank. test.php definitely returns something.
View 1 Replies
View Related
Mar 22, 2010
I spent 2 hours trying everything, but I still can't get it to work.
<html>
<head>
<title>Hi</title>
<script type="javascript">
var outcome1 = form.YesNo.value
if (outcome1 == no) {
var formResult = no
}
else {
[code]....
View 5 Replies
View Related
May 11, 2011
I wrote a function which animates an image which looks similar to this:
function animate()
{
var image = document.getElementById("frontImage");
var cssLeft = image.style.left;
[Code]....
This seems to be working fine. However, the image goes directly to its final position (100px to the right) and does not go through all the intermediate positions. As soon as I add an alert (the one which is now commented) everything works fine.
View 3 Replies
View Related
May 10, 2011
I'm trying to implement JQuery Cycle onto the homepage of my website (which is a work in progress). I wish to have a banner with Previous and Next buttons, as well as a Pager and a Caption. I've added all of this to the banner. The Pager and the Caption works, but for the life of me I can't get the Previous and Next links to work.
This is my code:
<script type="text/javascript">
$(document).ready(function() {
$('#banner').cycle({
fx: 'fade',
speed: 'fast',
timeout: 0,
prev: '#prev2',
next: '#next2',
pager: '#nav2',
after: function() {
$('#caption').html(this.alt);
}
});
});
</script>
<div id="banner"><!-- banner -->
<img src="<?php bloginfo('template_directory'); ?>/images/banner_image_1.jpg" alt="Louvre Museum, Paris"/>
<img src="<?php bloginfo('template_directory'); ?>/images/banner_image_2.jpg" alt="Louvre Museum, Paris 2"/>
</div><!-- /banner -->
<div id="nav"><a id="#prev2" href="#">Previous Image</a> - <a id="#next2" href="#">Next Image</a></div>
<div id="caption"></div>
<div id="nav2"></div>
My website can be viewed here: [URL]
View 2 Replies
View Related
Jun 30, 2011
I have a script that lets you add tasks to a task list and then you can click a button to sort them, but I cannot get the "Delete Selected Task" and "Delete All Tasks" buttons to work correctly. I will be eternally indebted to whoever can help me fix these two buttons. The code I am working on is posted below.
[Code]...
View 12 Replies
View Related
Sep 28, 2009
I'm trying to run through the simplest tutorials on jquery and for some reason I can't get any of the jquery code to work.I've downloaded jquery and I've made sure that this file is in the same directory as jquery-1.3.2.js.This is the code taken from the tutorial:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">[code]....
when the user clicks on the link it shouldn't take them to [url]....instead it should display an alert box. but it takes me to[url]...every time.
View 2 Replies
View Related
Feb 5, 2009
I am putting together a simple edit in place script. For some reason, in order for for the editEffect function I've created to work I need to use the alert function as seen in the code below. I can't figure out the cause of the problem and I believe the root cause is also creating other problems - i.e. in the cancelEdit function the argument "targetElement" is not alerted, but it is successfully submitted as an argument to another function.
/* Edit in place javascript code */
function editLightOn(element){
element.style.backgroundColor = "#ffc";
}
function editLightOff(element){
element.style.backgroundColor = "#FFFFFF";
}
[Code]..
View 4 Replies
View Related
Apr 10, 2010
Code:
<script>
var timer = 0;
function SpellItOut(word)
{
[code]....
View 3 Replies
View Related
Oct 31, 2009
I can't get the radio buttons to work properly in my browser. If you don't press one the alert box does not tell you that you have to tick either male or female. Also I noticed you can tick both but it won't say you must choose only one, how can I sort this..
case "radio_hidden":
if (fld.value != "1")/* radio male or female button should be checked*/
{
fld.valid = true;
[Code]....
View 1 Replies
View Related
Jul 23, 2009
I'm having a problem with my radio buttons. On FF and Chrome they work just fine, but in IE, they does'nt appear as sellected. In other words: they do their job, but when you click'em, they stay unckeched. The genetarion code:
var item = $('<input type="radio" />').attr('value',pid).attr('name',name);
self.append($('<p />').append(item).append('<label>'+desc+'</label>'));
View 1 Replies
View Related
Jun 8, 2010
I want the next and previous buttons on my carousel to work when I hover over them.
The way it works now is that the function only fires once each time I hover over one of the buttons.
View 1 Replies
View Related
Apr 15, 2009
java and i am having trouble getting radio buttons , check boxes and pull down lists to work in my form whenever i put them in there they just come up as undefined. And if i try to put any if statements in the hyper links stop working as the program cannot run. Obviously as i am doing something very wrong.I am at a loss and have spent hours on it and just cant get these things working.Any thing with a typed answer works great such as first name or last name here is the code i have written so far
<script>
function hidediv(divname) {
if (document.getElementById) { // DOM3 = IE5, NS6
[code].....
View 4 Replies
View Related
Jun 30, 2009
Why won't this work?
Nothing pops up for the alert.
<script type="text/javascript">
View 13 Replies
View Related