-
-
global and local variables with functions
Example 3 also works if i put the Javascript at the bottom of the page. Thank You for your help!
-
global and local variables with functions
Hello, The following codes are for use with xml data. Example 1 and 2 are working but example 3 does not, even if $x and $cards chould be global variables. I use $ sign before every variable as i found it easier to get around. Please explain why example 3 does not work comment any issues you find. code starts with: if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari $xmlhttp = new XMLHttpRequest(); }else{ // code for IE6, IE5 $xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } $xmlhttp.open("GET","bscard.xml",false); $xmlhttp.send(); $xmlDoc = $xmlhttp.responseXML; example 1: function display() { $x = document.getElementById("test"); $cards = $xmlDoc.getElementsByTagName("BusinessCard"); $cards = getElement(); $name = $cards[0].getElementsByTagName("name")[0].firstChild.data; $phone1str = $cards[0].getElementsByTagName("phone")[0].getAttribute("type") + ": "; $phone1 = $cards[0].getElementsByTagName("phone")[0].firstChild.data; $phone2str = $cards[0].getElementsByTagName("phone")[1].getAttribute("type") + ": "; $phone2 = $cards[0].getElementsByTagName("phone")[1].firstChild.data; $phone3str = $cards[0].getElementsByTagName("phone")[2].getAttribute("type") + ": "; $phone3 = $cards[0].getElementsByTagName("phone")[2].firstChild.data; $email = $cards[0].getElementsByTagName("email")[0].firstChild.data; $x.innerHTML = $name + "<br />" + $phone1str + $phone1 + "<br />" + $phone2str + $phone2 + "<br />" + $phone3str + $phone3 + "<br />" + $email; } examlpe 2: function getElement(){ $x = document.getElementById("test"); $cards = $xmlDoc.getElementsByTagName("BusinessCard"); return $cards; } function display() { $cards = getElement(); $name = $cards[0].getElementsByTagName("name")[0].firstChild.data; $phone1str = $cards[0].getElementsByTagName("phone")[0].getAttribute("type") + ": "; $phone1 = $cards[0].getElementsByTagName("phone")[0].firstChild.data; $phone2str = $cards[0].getElementsByTagName("phone")[1].getAttribute("type") + ": "; $phone2 = $cards[0].getElementsByTagName("phone")[1].firstChild.data; $phone3str = $cards[0].getElementsByTagName("phone")[2].getAttribute("type") + ": "; $phone3 = $cards[0].getElementsByTagName("phone")[2].firstChild.data; $email = $cards[0].getElementsByTagName("email")[0].firstChild.data; $x.innerHTML = $name + "<br />" + $phone1str + $phone1 + "<br />" + $phone2str + $phone2 + "<br />" + $phone3str + $phone3 + "<br />" + $email; } example 3: $x = document.getElementById("test"); $cards = $xmlDoc.getElementsByTagName("BusinessCard"); function display() { $name = $cards[0].getElementsByTagName("name")[0].firstChild.data; $phone1str = $cards[0].getElementsByTagName("phone")[0].getAttribute("type") + ": "; $phone1 = $cards[0].getElementsByTagName("phone")[0].firstChild.data; $phone2str = $cards[0].getElementsByTagName("phone")[1].getAttribute("type") + ": "; $phone2 = $cards[0].getElementsByTagName("phone")[1].firstChild.data; $phone3str = $cards[0].getElementsByTagName("phone")[2].getAttribute("type") + ": "; $phone3 = $cards[0].getElementsByTagName("phone")[2].firstChild.data; $email = $cards[0].getElementsByTagName("email")[0].firstChild.data; $x.innerHTML = $name + "<br />" + $phone1str + $phone1 + "<br />" + $phone2str + $phone2 + "<br />" + $phone3str + $phone3 + "<br />" + $email; }
-
php adding stuff
Hello, Try to put the $_POST['whatever'] in a variable and if it does not work check some string functions on php.net. Please note that using global variables is a big security issue. Regards
-
JavaScript function modification
Hello, I need a JavaScript function modification. This function replaces the content in messages div. I need two variables added to the function so i can call it like replaceContent(var1, var2, var3). var 1 and 2 are numbers, var3 is the name of the div. I would like to use this function in a form with onselect option. Please check function and form example below. Function: function replaceContent(){ //Send an XMLHttpRequest to the 'newcontent.php' file if(window.XMLHttpRequest){ xmlhttp = new XMLHttpRequest(); xmlhttp.open("GET","newcontent.php",false); xmlhttp.send(null); } else{ xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); xmlhttp.open("GET","newcontent.php.php",false); xmlhttp.send(); } //Replace the content of the messages with the response from the 'newcontent.php.php' file document.getElementById('messages').innerHTML = xmlhttp.responseText; } Form: <form> <select name="select1" id="select1"> <option value="1" onselect"replaceContent(var1, var2, var3)"> one </option> <option value="2" onselect"replaceContent(var1, var2, var3)"> two </option> </select> <select name="select2" id="select2"> <option value="1" onselect"replaceContent(var1, var2, var3)"> one </option> <option value="2" onselect"replaceContent(var1, var2, var3)"> two </option> </select> <select name="select3" id="select3"> <option value="1" onselect"replaceContent(var1, var2, var3)"> one </option> <option value="2" onselect"replaceContent(var1, var2, var3)"> two </option> </select> </form> Thank you for your help!
-
Self Employed or Umbrella Company ?
In this case you pay all your profit to yourself by PAYE. Do you have to pay anything other than income tax and NI? Is there any rate to pay if the company employes 2 person? I sow somewhere, there is a 12% rate to pay on egross wages after every employee. Is thistrue?
-
need some help
In this case if a spammer enter a valid but not existed email you still get junk mails. Try loog after a freeware email validation script. Check how it works then write your own.
-
-
Need help with Mysql query
Thank You! It`s working now!
-
-
Need help with Mysql query
Thanks for the help. Yes there is a SEO link but the site is my and it is not a part of a paid link building.
-
Need help with Mysql query
Hi all! I have an internet radio website. I need help with a mysql query. I want my result contain only the id`s "WHERE `visible`=1" but i can not work it out. Current query generated by my script: $query = "SELECT * FROM radios WHERE id=10 OR id=32 OR id=42 OR ..."; Please help!
-
Why phpbb header mod doesn`t work?
I installed the forum on my localhost. When i want to refrech it says there is no need to refrach because the files are stored in the file system or something like that. I deleted then installed the style but nothing happened! When i opened and saved the template in phpbbs built in editor (no changes made at all) it worked. Thanks!
-
Why phpbb header mod doesn`t work?
Sorry for foul language!
-
Why phpbb header mod doesn`t work?
I modifed phpbb3 subsilver 2 theme. I want to remove the header but my changes in overall_header.html doesnt have any effect. Any ideas?
-
Desktop monitors vs laptop monitors
Hi! You should look around at the webshops for better prices and hardware. There are many high end stuff. 1920 x 1280 res is normal in the price range above £200. I recommend desktop pc. It is cheaper to upgrade and for a £1000 you get 2 times better stuff then when you buy a laptop. Visit http://www.ebuyer.com , http://www.overclockers.co.uk , http://www.saverstore.com/. Regards
-
Advice needed for Photographer's site
Hi! It is done in flash with XML database. Maybe i can help. Sorry i am busy now i will post again later.
-
Advice needed for Photographer's site
How is your project going on?