Is javascript updating before mysql finishes?

, I have a fun application I did for class the other day. I noticed a little bug in it though. I've already turned it in, but I want to know what I could be doing better for my own benefit.

The assignment was to create a mysql database, put some information into it, and then be able to update it and view the updates (I paraphrase for brevity). I created everything just fine, and I decided that I want the site to be ajaxy. I put 2 tables reflecting data in the database, but for some reason, the tables only sometimes update with ajax. sometimes they do, sometimes they don't. I feel like the response might be getting sent back before mysql finishes updating, but I'm just speculating. This was my first time using ajax with jQuery, in the past I had to implement with pure javascript (assignment's rules, I wanted to use jQuery).

To run the site, just make sure you have mysql installed, you can adjust the security credentials in functions.php. I know that this site is very open to SQL injection, but that wasn't a concern for me for this assignment.

Here's the code:

Admin var stateRegEx = /^((AL)|(AK)|(AS)|(AZ)|(AR)|(CA)|(CO)|(CT)|(DE)|(DC)|(FM)|(FL)|(GA)|(GU)|(HI)|(ID)|(IL)|(IN)|(IA)|(KS)|(KY)|(LA)|(ME)|(MH)|(MD)|(MA)|(MI)|(MN)|(MS)|(MO)|(MT)|(NE)|(NV)|(NH)|(NJ)|(NM)|(NY)|(NC)|(ND)|(MP)|(OH)|(OK)|(OR)|(PW)|(PA)|(PR)|(RI)|(SC)|(SD)|(TN)|(TX)|(UT)|(VT)|(VI)|(VA)|(WA)|(WV)|(WI)|(WY))$/; function updateOwnerData() { document.create_edit_owner.state.value = document.create_edit_owner.state.value.toUpperCase(); if( document.create_edit_owner.first_name.value.length > 0 && document.create_edit_owner.last_name.value.length > 0 && document.create_edit_owner.age.value.length > 0 && parseInt(document.create_edit_owner.age.value) > 0 && parseInt(document.create_edit_owner.age.value) < 255 && stateRegEx.test(document.create_edit_owner.state.value) ){ $.post('transaction.php', { type: "updateOwner", OID: document.create_edit_owner.OID.value, first_name: document.create_edit_owner.first_name.value, last_name: document.create_edit_owner.last_name.value, age: document.create_edit_owner.age.value, state: document.create_edit_owner.state.value }, function(output){ $('#create_owner_result').html(output).show(); }); updateTable("owner","ownerTable"); populateOwnerSelects(); }else{ alert(" fields must have a value, state must be a valid state, age must be a number between 1 and 254 inclusive"); } } function resetOwner(id){ document.create_edit_owner.OID.value = "-1"; document.create_edit_owner.first_name.value = ""; document.create_edit_owner.last_name.value = ""; document.create_edit_owner.age.value = ""; document.create_edit_owner.state.value = ""; document.loadOID.OID.value = ""; $('#load_owner_result').html("").show(); } function getOwner(){ $.post('transaction.php', { type: "loadOID", OID: document.loadOID.OID.value }, function(output){ var out = jQuery.parseJSON(output); document.create_edit_owner.OID.value = out.OID; document.create_edit_owner.first_name.value = out.first_name document.create_edit_owner.last_name.value = out.last_name document.create_edit_owner.age.value = out.age document.create_edit_owner.state.value = out.state $('#load_owner_result').html(out.message).show(); }); } function deleteOwner() { $.post('transaction.php', { type: "deleteOwner", OID: document.delete_owner.OID.value }); updateTable("owner","ownerTable"); updateTable("vehicle","vehicleTable"); populateOwnerSelects(); } function queryByOwner(){ $.post('structures.php', { table: "ownerQuery", OID: document.query_by_owner.OID.value }, function(output){ $('#ownerQuery').html(output).show(); }); } function updateVehicleData() { if( parseInt(document.create_edit_vehicle.year.value) > 1901 && parseInt(document.create_edit_vehicle.year.value) < 2155 && document.create_edit_vehicle.year.value.length > 0 && document.create_edit_vehicle.make.value.length > 0 && document.create_edit_vehicle.model.value.length > 0 ){ $.post('transaction.php', { type: "updateVehicle", VID: document.create_edit_vehicle.VID.value, OID: document.create_edit_vehicle.OID.value, year: document.create_edit_vehicle.year.value, make: document.create_edit_vehicle.make.value, model: document.create_edit_vehicle.model.value, color: document.create_edit_vehicle.color.value }, function(output){ $('#create_vehicle_result').html(output).show(); updateTable("vehicle","vehicleTable"); }); }else{ alert("Year must be between 1901 and 2155 and all fields must have some value"); } } function deleteVehicle() { $.post('transaction.php', { type: "deleteVehicle", VID: document.delete_vehicle.VID.value }); updateTable("vehicle","vehicleTable"); } function resetVehicle(id){ document.create_edit_vehicle.VID.value = "-1"; document.create_edit_vehicle.year.value = ""; document.create_edit_vehicle.make.value = ""; document.create_edit_vehicle.model.value = ""; document.create_edit_vehicle.color.value = ""; document.loadVID.VID.value = ""; $('#load_vehicle_result').html("").show(); } function getVehicle(){ $.post('transaction.php', { type: "loadVID", VID: document.loadVID.VID.value }, function(output){ var out = jQuery.parseJSON(output); document.create_edit_vehicle.VID.value = out.VID; document.create_edit_vehicle.year.value = out.year; document.create_edit_vehicle.make.value = out.make; document.create_edit_vehicle.model.value = out.model; document.create_edit_vehicle.color.value = out.color; for (var i = 0; i < document.create_edit_vehicle.OID.length; i++) { if (document.create_edit_vehicle.OID.options[i].value == out.OID) { document.create_edit_vehicle.OID[i].selected = true; break; } } $('#load_vehicle_result').html(out.message).show(); }); } function queryByVehicle(){ $.post('structures.php', { table: "vehicleQuery", VID: document.query_by_vehicle.VID.value }, function(output){ $('#vehicleQuery').html(output).show(); }); } //validate age with ^([1-9][0-9]*)$ $(document).ready(function(){ updateTable("owner","ownerTable"); updateTable("vehicle","vehicleTable"); populateOwnerSelects(); }); function updateTable(name, whichTable) { $.post('structures.php', { table: name }, function(output){ $('#'.concat(whichTable)).html(output).show(); }); } function populateOwnerSelects(){ $.post('structures.php', { table: 'ownerSelectBox' }, function(output){ $(".owners").html(output).show(); }); } This section is for creating a new owner or updating an existing one.
If you want to create a new owner, there is no need to enter an ID.
If you want to edit an existing owner, please load the owner using
the owner ID in the 'Load Owner from ID' section.
First Name
Last Name
Load Owner from ID
Use this to load pre-existing owners for editing
ID Owners
Delete Owner By ID ID Get vehicles owned by a given owner Owner ID This section is for creating a new vehicle or updating an existing one.
If you want to create a new vehicle, there is no need to enter an ID.
If you want to edit an existing vehicle, please load the vehicle using
the vehicle ID in the 'Load Vehicle from ID' section. This can also be
used for changing the owner of an existing vehicle.
Owner ID
Load Vehicle from ID
Use this to load pre-existing vehicles for editing
ID Vehicles
Delete Vehicle By ID ID Get the owner of a given vehicle Vehicle ID


Posted On: Sunday 23rd of December 2012 10:40:07 PM Total Views:  487
View Complete with Replies

Related Messages:

problame with updating data automatic from database...please help   (262 Views)
hello , I made a simple messageing script with php and when i send message somebody he need to refresh his page for biew new message... but i want that will be automatically show to him after i send message, thats mean when i send a message to anybody it will be shown to him without refresh like facebook chatting so i need help, i need that script which will be help me to retrive data from database without refresh ... if u know then please help me Thank You in advance
javascript works in IE but not working in firefox   (153 Views)
List of Sleep Studies Entities : 1, Instances : 1NARMC Sleep Disorders Clinic Intake Form Last Name: First Name: Age: Gender: Clinton Harry 32 Years M General Physician Sleep History Sleep Behavior Med Hist Ref Physician Breath Narcolepsy Disorders GeneralGeneral Information Patient Data Patient Name: Last Name:Req First Name: MI: Personal Information: Age: Gender:MF Birthday: Why is there airTo Breathe.To Fill Basketballs.Other Contact Information: Home Phone: Work Phone: E-Mail: Address: Street: City: State: Zip Marital Status:SingleMarriedDivorcedWidow(er) Physical Description: Height: Body Frame:SmallMediumLarge Weight (Lbs): Race:African-AmericanAsianCaucasianHispanicNative American Please give a brief description of your clinical complaint and its duration, especially as it relates to sleep: Please describe any events which occur while falling asleep, during sleep or while waking up that you consider unusual: Which of the following games do u play. Select all that apply:FootballSoccerBasketballTennisCricket PhysicianPatients Physician Doctor Name: Newname Sleep HistorySleep History Do you feel you suffer from insomnia Yes No Do you feel that you get too little sleep at night Yes No Do you feel you get much sleep at night Yes No Weekday Bedtime (hh:mm) Please select:ampm Weekend Bedtime (hh:mm) Please select:ampm Weekday Wakeup (hh:mm) Please select:ampm Weekend Wakeup (hh:mm) Please select:ampm How long does it usually take to fall asleep (mins) How long are you awake in the morning before you actually get out of bed (mins) Sleep BehaviorSleep Behavior Do your legs or arms bother you when resting or falling asleep Yes No Please Describe: Do you have unusual movements (Leg Jerks, Head Movements, etc.) during sleep Yes No Please Describe: Do you have any unusual sleep behavior (sleep walking, sleep talking, etc.) Yes No Please Describe: Do you experience dreamsYesNoSometimes Have you noticed a change in your dreams (i.e. increased, decreased, more action packed, etc.) Yes No Please Describe: Do you experience nightmares Yes No Please Describe: Med HistMedical History Have you had high blood pressure Yes No How long How is it being treated (medication, diet, etc.) Have you ever had a seizure Yes No Please Describe: Do you suffer from recurrent dizzy spells Yes No Have you ever experienced a rapid or pounding heart beat Yes No Have you had a Heart attack or stroke Yes No Please Describe: Do you have a history of Diabetes Yes No How long How is it being treated (medication, diet, etc.) Have you tested positive for HIV Yes No Have you been told that you have TB or had a positive PPD test Yes No Please list any medications you take on a regular basis: Name of Drug Reason Dosage (e.g.-20 mg/day or .05 mg every other day) Last Dose (Date) (mm/dd/yyyy) Aspiron Headache 10 mg 08/23/2003 Citamol Fever 20 mg 05/25/2004 Paracitamol Fever 100 mg 04/28/2004 Have you experienced a change in body weight Yes No Gained (lbs): Lost (lbs): Over what time Perioddaysweeksmonths Do you currently use tobacco Yes No Cigarettes/day how many years test Name of Referring Physician: Office Phone: Office Fax: Ref PhysicianReferring Physician Data List all your current medications Name of Drug Reason Dosage (e.g.-20 mg/day or .05 mg every other day) Last Dose (Date) (mm/dd/yyyy) A R1 Ds1 D1 B R2 Ds2 D2 C R3 Ds3 D3 D R4 Ds4 D4 E R5 Ds5 D5 F R6 Ds6 D6 Do you like Pizza Yes No Best Friend Last Name:Req First Name: MI: Doctor: Name: Dorian BreathBreathing Disorders Do you experience any breathing problems during sleep Please Describe: Have you been told that you snore Yes No Have you been told that you have breathing pauses during sleep Yes No Do you have difficulty breathing in a flat position Yes No Do you ever wake up short of breath Yes No Do you ever wake up choking or gasping for air Yes No Do you use breathing devices such as CPAP/BiPAP Type of CPAP/BiPAP unit: CPAP Pressure: Date of starting CPAP usage: Type of Humidifier: NarcolepsyNarcolepsy Have you ever been diagnosed as having Narcolepsy Yes No Has anyone in your family been diagnosed with narcolepsy Yes No feeling sleepy or fatigued after an emotional experience 1 2 3 4 5 not being able to move when first waking up 1 2 3 4 5 daytime hallucinations or dreaming 1 2 3 4 5 sleep attacks (falling asleep despite not wanting to) 1 2 3 4 5 DisordersMedical Disorders "gas", indigestion or heartburn 1 2 3 4 5 awakening due to regurgitation or throat burning 1 2 3 4 5 waking up coughing 1 2 3 4 5 waking up with the need to urinate 1 2 3 4 5 nasal congestion 1 2 3 4 5 1 records.
A simple function problem   (260 Views)
My exercise is as follows: Write a program that invites the user to estimate one minute of time. The user should click on a button on the screen, and then click on the button again after what he/she estimates to be one minute. The program then displays the true length of time. If the user still hasn't clicked on the button after 5 minutes have elapsed, the program should display a "Ah! Come on!" message. On first press of the button I am getting the alert I shouldn't get until after the second click of the button with NaN as the seconds elapsed. Any ideas Here is my code: Guess 1 Minute
Dynamic Adding of Elements - doesn't work   (160 Views)
Hi , I am still new to JavaScript. In our class we were required to create an application wherein you can dynamically add elements and use them. I don't know what I am missing here. Any ideas
Function works and then says not defined   (195 Views)
I have some code to dynamically retrieve one of three AJAX files and insert it into a DIV The Javascript is function createajax() { var Ajax; try{ Ajax = new XMLHttpRequest(); } catch (e){ try{ Ajax = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try{ Ajax = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e){ alert("Error!!!"); return false; } } } return Ajax; } function basicAjaxSwitch(File, Recipient, Animate) { if ( Animate == true ) { Animation(document.getElementById(Recipient)).duration(100).from('opacity', 1).to('opacity', 0).go(); } basicAjaxSwitch = createajax(); basicAjaxSwitch.onreadystatechange = function(){ if(basicAjaxSwitch.readyState == 4){ if ( Animate == true ) { Animation(document.getElementById(Recipient)).duration(100).checkpoint().duration(100).from('opacity', 0).to('opacity', 1).go(); setTimeout('document.getElementById("'+Recipient+'").innerHTML = basicAjaxSwitch.responseText;', 100); } else { document.getElementById(Recipient).innerHTML = basicAjaxSwitch.responseText; } } }"GET", "/ajax/"+File, true); basicAjaxSwitch.send(null); } function changesidebarinfo(changeto) { if ( changeto == 'login' ) { Animation(document.getElementById('main_layout_accountlinks_background')).to('left', '0px').duration(100).go(); Animation(document.getElementById('main_layout_accountlinks_login')).duration(100).to('color', '#FFF').go(); Animation(document.getElementById('main_layout_accountlinks_signup')).duration(100).to('color', '#000').go(); Animation(document.getElementById('main_layout_accountlinks_about')).duration(100).to('color', '#000').go(); basicAjaxSwitch('contentinfo/login.php', 'main_layout_rsbinfo_container', true); } else if ( changeto == 'join' ) { Animation(document.getElementById('main_layout_accountlinks_background')).to('left', '50px').duration(100).go(); Animation(document.getElementById('main_layout_accountlinks_login')).duration(100).to('color', '#000').go(); Animation(document.getElementById('main_layout_accountlinks_signup')).duration(100).to('color', '#FFF').go(); Animation(document.getElementById('main_layout_accountlinks_about')).duration(100).to('color', '#000').go(); basicAjaxSwitch('contentinfo/join.php', 'main_layout_rsbinfo_container', true); } else if ( changeto == 'about' ) { Animation(document.getElementById('main_layout_accountlinks_background')).to('left', '100px').duration(100).go(); Animation(document.getElementById('main_layout_accountlinks_login')).duration(100).to('color', '#000').go(); Animation(document.getElementById('main_layout_accountlinks_signup')).duration(100).to('color', '#000').go(); Animation(document.getElementById('main_layout_accountlinks_about')).duration(100).to('color', '#FFF').go(); basicAjaxSwitch('contentinfo/about.php', 'main_layout_rsbinfo_container', true); } } And the HTML that triggers the actions is   Log In Join About When I click one of the 3 buttons (doesn't matter which) the result is exactly as intended. Then when I click another (or the same) button, nothing happens and Firebug gives the error basicAjaxSwitch is not a function changesidebarinfo("login")site.js (line 61) function onclick(event) { changesidebarinfo("login"); }(click clientX=816, clientY=41)2 (line 2) [Break on this error] basicAjaxSwitch('contentinfo/login.php...'main_layout_rsbinfo_container', true);\n
How to change ONLY the color of text on MouseOver/Out?   (184 Views)
This is what happens: I have an input submit button. On mouse over text is changed from RED to WHITE. On mouse out text is changed from WHITE to RED. Simple eh Well IE does it fine but FF makes everything change to RED border, etc. jscript: function over(button) { = "#FFFFFF"; } function out(button) { = "#FF0000"; } my input button: Any Ideas
Ajax javascript test if image file exists   (182 Views)
Hi , I need the help of a real expert because I'm still having difficulty with this Ajax technique. I have posted before about this on another site forum, but no replies (sigh). The script below works with FF only when the alert is in the code, and doesn't work at all in IE. Of the numerous posts on the net about doing this, none seem to work at all. I believe that the IE portion of the problem has to do with the req.readyState or req.status, maybe. But in FF, why is the alert necessary for the req.readystatechange to work Or, what else is the alert doing that I need to do Something about clearing an error of trying to get a file header that doesn't exist Oh, by the way, if I just go ahead and don't do anything at all, then it displays all of the existing links fine and just inserts 'X' for missing images when they don't exist, which is roughly 60% of the time, so that's not an acceptable approach, specially if the first several are the missing ones. The html page is delivered from a php page at the end of a series of php login and verification pages, but I've tested this as a standalone - same thing. The image links are retrieved from an array, and there is absolutely no problem there - only in testing if the file exists so the array can be collapsed before going into the display routines. nB is declared as a global variable, btw. My code is this: last part of main function call: // collapse imagelink array removing missing elements // for (m=imagetotl-1;m>=3;m--) { testExists(imagelink[m]); alert("test"); //this statement that must be here to make it work! (What gives ) // if(nB) { imagetotl--; for (n=m;n
Make a Tree Menu   (147 Views)
I would like to make a tree menu with category and sub category in Php. When i click on category then display subcategory with link that subcategory page. it is with mysql database. Im tried to make this but I can't. I want to use the tool ( ) for it, but I dont know if the tool can help me make a wonderful tree menu, if someone used or known about it, please tell me how should I do.
Table with image   (169 Views)
I need to create a table: inside a table i must have the picture with a heading, link> ,abstract and full story, read more news. When clicking on the link 1 of 2 the image must change along with the heading and abstract.
username availability gmail-style (javascript+sql)   (208 Views)
Hi all. I am currently developing a CMS for a school project and I wanted to add the function to check, real-time, if a username is already taken. It should be a little bit like what happens when you register for a Gmail or Yahoo! account. Basically, while the user inputs the deed username in a textbox, I want to make appear next to it a green or red sign (plus a small text) to display availability. The registered usernames will be in a mysql table which I can query with a very basic SELECT statement. It should work AS THE USER TYPES, so if he's entering "mrbrown" then it should try to query for every letter. This will be my first AJAX implementation, so I am asking for a starting point and any suggestion you deem could help me.
jQuery GalleryView - Loading via ajax not working   (188 Views)
Using jQuery's plugin GalleryView I am able to get the gallery to load on a page refresh with $(document).ready(function(){ $('#photos').galleryView({show_panels: true,show_filmstrip: true,panel_width: 400,panel_height: 300,frame_width: 100,frame_height: 100}); }); I even tried that with the jQuery livequery plugin, which creates an infinite loop. I tried searching google for a solution, and only found one thread after extensive searching of people having the same issue of getting this plugin to work with ajax, but there was no solution. this is the thread http://stackoverflow...l-containing-js My html looks like this
window.location troubles   (186 Views)
To make a long story short when I do a redirect like this... if(window.location.hash.length > 0){ window.location = "http://" + "" + "/" + window.location.hash; } it goes there, but on the refresh php can't see what was appeneded with the window.location.hash, so its like I'm going to window.location = "http://" + " " thoughts, ideas if I got to that generated URL, without the redirect, it works fine. please and
Pressing the submit button after amount of time ?!   (201 Views)
Hi all, I need some help i have an HTML page with a form on it. I simple need a script witch will press the submit button after a while (3 sec for instance)
How can I write the script?   (212 Views)
first name Same as first name second name This coding can only when click the checkbox. It will fill same value from textfield ab to textfield zb But I want to when click the checkbox. it will also make the same value from textfield bb to textfield yb How can I write the script
changing an AJAX $_GET to $_POST   (271 Views)
I have found the following code and wish to have it do a POST instead of the GET can someone tell me what needs changing so this does a POST ajax.php
Retrieving values from html tables   (260 Views)
I have populated data in html table. Now I have to retrieve the value from this table, row-wise. How can i do this. Please help...
Object required error   (240 Views)
I'm playing with javaScript and AJAX and using the source code used in this page: (Actually I copied the code on the Default.aspx to the page I was working on, which has a MasterPage and translated Default.aspx.cs from C# to VB.NET) However, I'm having an "Object Required Error" in the line = "block"; Any ideas why is this happening
Creating table dynamically   (281 Views)
Hi I am able to create a row dynamically with 3 cells(i.e column). In my 3rd cell i need to add another row. Is it possible to acheive it. I am using Java script for it. This is the table structure: Select Decimal Masking Date Decimal Point Decimal Format Select Masking Text Mask Position Select Left Right Source Format Output Format
LogicWeb AJAX   (143 Views)
Greetings, When you *initially* load LogicWeb's home page, it hesitates for about 1-2 seconds on loading the ajax tabs up top (you can't miss it, right below main navigation bar). I am trying to figure out why this happens, but I just cannot seem to grasp the cause. I am not a designer / programmer by trade so I'm not quite sure what to look for within the javascript files. Javascript:
Need help with code - grabbing width and height of?   (198 Views)
I need help I am pretty new to JavaScript... I try my best at it but I am getting lost and need some help. What I want to do is grab an elements width and height and apply it to a window or a popup window. In my case this is what currently have and I can't seem to get any further.. thanks in advance. Untitled Document var contentHTML = "Couldn't find content"; function popup(obj) { var contentName = obj.parentNode.childNodes; for (var i=0; i
jquery background color css   (239 Views)
I am trying to check for the background of an element, here is my code. But it doesn't work: I tried two ways, here is the first: function changeColor(field) { if(field.css('background-color','#ffb100')) { field.css('background-color','white'); } else { field.css('background-color','ffb100'); } } here is the second: function changeColor(field) { if(field.css('background-color') === '#ffb100') { field.css('background-color','white'); } else { field.css('background-color','ffb100'); } } But neither worked! Any suggestions
BODY onload is not working   (168 Views)
Hi , I'm using ajax to display the xml file. On my html i put so everytime users go to the main.html, all the information in xml will be displayed after transformed by XSL Now the problem is it gets the errorDisplay is not defined While i did define it in js file this is what I do in js; var xhr = createRequest(); function sendRequest(data) { if(xhr) {"GET","product.phpid=" + Number(new Date) +"&value=" + data, true); xhr.onreadystatechange = function() { if (xhr.readyState == 4 && xhr.status == 200) { var divtag = document.getElementById("product"); divtag.innerHTML = xhr.responseText; } } xhr.send(null); } } xhr has another file for it* in php file; load('items.xml'); $transformedXml = $processor->transformToXml($xml); echo($transformedXml); break; } > in my xsl; Can anyone tell me what's wrong with the code
I want to keep the drop down box value   (199 Views)
, My code i pretty messed up at the moment but i was hoping someone could help me change it so that when the form is reloaded the 2nd time round that the value in the drop down menu that's selected stays after the reload. Postcode and Address Selection Test //Reloads the page function reload(form) { var val=form.postcode.value; self.location='dd.phppostcode=' + val; } function reload2(form) { var val=form.postcode.value; var val2=form.suburb.options[form.suburb.options.selectedIndex].value; self.location='dd.phppostcode=' + val + '&suburb=' + val2; }
setInterval inside function issue   (373 Views)
what i want to do is this: function foo(param1, param 2){[INDENT]{[INDENT]this.intervalID=setInterval(this.fbar,5000);[/INDENT]} this.fbar=function(){[INDENT]//(do stuff with the properties of "this" alert(this.intervalID);[/INDENT]} [/INDENT] } but setInterval will not carry over the properties of "this". when this happens: var apple=new foo(5,27);; i need apple.fbar(); to repeat automatically by force of; note: fbar does not have to be inside of the foo function but i do need to get all of "this"'s properties to it durring a setInterval
Please help!!   (202 Views)
remove p tag from DOM tree   (202 Views)
This should be a simple one, and yet I need help to solve the problem: I need to remove the element with the class "goup" on it from the DOM tree with javascript (eventually with prototype, but no other library). I don't only want to hide that paragraph, but remove it entirely from the DOM tree. My solution to use getElementsByClassName does not work. function hidegoup() { var goup= document.getElementsByTagName("p") .getElementsByClassName("goup"); = 'none'; goup.removeChild(); } THE HTML: To the top of the page
Changing the colour of an tag   (167 Views)
Example 1 The button is a blob of colour (.jpg) with text over the top. I want two things to happen: first, when the cursor is rolled over the .jpg and then the text, I want the text to change colour. This works ok. Second, I want to link to industry.php when clicked. This works ok over the .jpg but, obviously, not over the text. [code = PHP] echo ' Industry '; [/code] [code = CSS] #industry_button { position:relative; top:60px; left:-100px; float:left; font-size:14px; color: #066; } #industry_button .text { position:absolute; top:7px; left:10px; float:left; cursor:pointer; } [/code] [code = Javascript] function Roll_Industry(mouse) { if (mouse == true) { document.getElementById("industry_button").style.color="red"; } else { document.getElementById("industry_button").style.color= "#066"; } } [/code] Example 2 Similar to Example 1 with tag around the text. The linking is now ok but the colour change does not occur when the cursor is over the .jpg It does change colour when the cursor is over the text. I suspect that my problem lies with the Javascript. The alert's show that the javascript is being executed. [code = PHP] echo ' '; [/code] [code = CSS] #home_button { position:relative; top:60px; left:-120px; float:left; font-size:14px; } #home_button .text { position:absolute; top:7px; left:10px; float:left; cursor:pointer; } #home_button .text a { color:#fff; } #home_button .text a:hover { color:#ff0000; } [/code] [code = Javascript] function Roll_Home(mouse) { if (mouse == true) { alert("foo"); elem1 = document.getElementById("home_button");"red"; } else { alert("foo1"); document.getElementById("home_button") "#fff"; } } [/code]
Page Load Cancel Event   (175 Views)
I experimented with a snippet of JavaScript that will display a "Please Wait" message and graphic while the results of a cgi script is running (the script grabs a bunch of data and formats it in a table). Once the ...
"function" is not defined - error   (168 Views)
I've been sitting for a few hours now with a bug and can't seem to get a fix for. It is for an existing site that is being fixed temporarily and then going to be redeveloped in a few ...