JQuery :: Display An Alert Box - Code Does Not Work?
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:
I am a novice, almost to an intermediate-level JavaScript guy, so much of this is new to me. I appreciate your patience reading this.
I have a routine that creates some HTML on the fly (updateFilters() function) and after the HTML is created, I attempt to access some fields (elements) on the form itself.
I works fine if I place an alert() statement after the HTML is created, but when I remove, the code errors out.
I have tried the setTimeout() statement, but I cannot grab the element --- undefined or null is returned. It seems that the form is the only element I can get a handle on --- everything else is undefined or null...
Here is the code:
function editQuery() { var f; var x; var myForm = document.forms[0]; // Get the row filters that were used in the last query.. for (f = 1; f < 16; f++) { var filter = eval("myForm.FilterList_" + f); if (filter.selectedIndex > 0) { var methodElement = element("FilterMethod_" + f); var methodIndex = methodElement.selectedIndex; var savedFilterMethodValue = methodElement.options[methodIndex].text; var choicesElement = element("FilterChoices_" + f); var choicesIndex = choicesElement.selectedIndex; if (isNaN(choicesIndex)) { var savedFitlerValues = choicesElement.value; } else { var savedFitlerValues = choicesElement.options[choicesIndex].text; } updateFilters(filter); // update the filters // take the saved methods and values and then update the selections // Alert here makes the code work.. // alert("Try this"); // Wait for HTML.. setTimeout("completeEdit()", 1000); function completeEdit() { // Since the object was updated, get the object again.. var methodElement = element("FilterMethod_" + f); for (x = 0; x < methodElement.options.length; x++) { if (methodElement.options[x].text == savedFilterMethodValue) { methodElement.options[x].selected = true; break; } else { methodElement.options[x].selected = false; } } // Since the object was updated, get the object again.. var choicesElement = element("FilterChoices_" + f); for (x = 0; x < choicesElement.options.length; x++) { if (choicesElement.options[x].text == savedFitlerValues) { choicesElement.options[x].selected = true; break; } else { choicesElement.options[x].selected = false; } } // Only display next row if f = 2.. // If only one row was used, no reason display the next row.. if (f == 2) { displayNextFilter(f - 1); // display it } } clearTimeout(timeOut); } } }
Do I have to pass the object (the form, the elements) to the completeEdit() function in the setTimeout() statement?
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]..
This works fine when I place this code under the html in the main source, but if I try to add this Jquery code to an external js sheet it doesnt seem to work?
Currently my js sheet is called in the header, when I move this link to the footer of my page the code works again, so Im guessing this has something to do with where the jquery code is placed in relation to the code Im trying to hide?
How I can keep my js in the header but still make the content disappear on click?
I have a classified listing application (php) that shows an alert message on the main page to let the user know if there was an error, if the listing was entered, if a required field was left blank, etc.
the alert msg. displays whenever the page is loaded. However, if someone navigates with the forward or back buttons in the browser, or reloads the page, the alert message displays again.
I am pulling my hair out for a solution that shows the alert only once and then does not show an alert again until a new message is generated.
This one is throwing me. I have a small piece of code that I am using to call a function in dynamic drive's accordion menu script. As long as I leave the alert() line in, it works. Comment it out and the call to expandone() doesn't go through. I must be missing something obvious, no? Here's the relevant part of the code (it is fired from $(document).ready() ):
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?
When i use $.get without alert() my code not working into asp.net ( updatePanel and ScriptManager for asp.net ). if i use this code in firefox dont work:
I'm very new to jQuery, only picked it up yesterday, so there is very little I understand at the moment. I have a website on which I would like to display a real time, time-series chart displaying results from a database that is constantly updated. how to pull live data from my database and display it in an alert box on my sight. One of the replies said I should use jquery to achieve this.
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]..
How to display an alert message with a scroll bar attached?
If this is not applicable, then how to display a popup message with a scroll bar, which acts completely as an alert message in its behaviour, meaning that the user can not act on the page except when he confirms the alert?
how to get the alert box to display in text instead. So when the user clicks on the submit button instead of an alert box, the result would display below the button in text instead of an alert?
<script type = "text/javascript"> function validate (form){ var hrs=(form.hrs[0].checked)? form.hrs[0].value : form.hrs[1].value;[code].....
I have been being banging my head against this for hours. I have an iframe that contains XML. All I want to do is display the XML content in a JavaScript alert. Here is what I have figured out.
This code retrieves the XML document object from the IFrame.
So I tried a simple alert on this and I receive the message:
So I think at this time, I have an XML Object.
So I tried this code:
Code:
Running this code, all I get back is an empty alert message which has me confused.
function Search( name, category ) { var sresults = []; var sri = 0; if( category != "Any" )
[Code]...
This is probably the weirdest thing I've ever seen. I know the code works since Firefox will output things, but it ONLY outputs when I throw in an alert statement somewhere in the function that gets called. It doesn't matter if it's at the beginning and just says Hi, but then it will run correctly. Without it, Firefox won't go through the function apparently and won't write out the results. I don't understand why this isn't working or why firefox is doing this.
I tried to display an alert window (avoid pop up since some users blocks it and hence not displayed on onload event in body) But it is not displayed properly like popup window.
So, I am in a Web Development class right now for my liberal arts science credit. We are on a lab dealing with JavaScript and half of it is making the values of some check boxes and stuff show up when the user clicks a "Display" button. I'm not sure I'm explaining it well. Here's the lab:
# In lab 6 you wrote a JavaScript function that displayed the name and email entered from the form. Extend that function to display all of the information the user entered in the form (name, e-mail, region, special interests, interest level, and comments). See if you can nicely format what shows in the alert message. The following hints should help:
1. The first step is to make sure that each GUI field has an id attribute set. For example the name field might have id="name". Remember, every id value must be unique. Two radio buttons will have the same name attribute value, but their id attributes must be unique. You need to do this so JavaScript can find the tags using the document.getElementById method.
2. To display your checkbox information, you will need to include logic as described in the following steps. Once you do this, do the same thing for the radio buttons.
1. Assume you have a checkbox with id="cherokee". Of course, your id attributes will likely have different names. The general steps will be the same, but substitute your names where I'm using "cherokee".
2. The following statement creates a Boolean value (true, false) that determines if the user checked the cherokee checkbox. The checked property in checkbox and radio button objects gives this information.
I am trying to get a checkbox to display an alert when the user clicks the checkbox for "other". Then if they click it again to unchedk it, it should not display the alert again. I keep getting an message that says not an object. Can anyone help me out with this? I have copied the code below for the checkboxes and the code that is in my .js file....