Jump to content

tjmbc

Members
  • Posts

    26
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

tjmbc's Achievements

Member

Member (2/5)

0

Reputation

  1. I am trying to write a simple function that makes a div change background colors randomly. Here's the code so far: function setBackground() { var digit = new array('0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'); //Creates an array with hex digits. digit.sort(function() {return 0.5 - Math.random()}); //Randomizes the above array. clr = "+" + digit[0] + digit[1] + digit[2] + digit[3] + digit[4] + digit[5]; //Puts the array in color form (ie. #00ff00). boxdiv.style.backgroundColor = clr; //Sets the background color of the div tag. } The code doesn't work. If I put the line... boxdiv.style.backgroundColor = "#00ff00"; ... it will change the color. (The function is tied to a buttons 'onClick' event). Anyone know what I'm missing?
  2. I am clueless about ajax so bear with me... I know that you have to use a "prototype.js" file to run an ajax script, but does your server have to have something to be 'ajax enabled'?
  3. This is a portion of my code that I am having problems with with the xml page pasted below. The script runs fine when I don't include the height and I can replace height with "width" and it will work. I just can't figure out why the code doesn't work when I try to parse the height. I pasted my full code at the bottom of this post. function getXMLSuccess(originalRequest) { var resultText = ""; var response = originalRequest.responseXML; var heights = response.getElementsByTagName('height'); var widths = response.getElementsByTagName('width'); var bgColors = response.getElementsByTagName('bgcolor'); var borders = response.getElementsByTagName('border'); var height = heights[0].firstChild.nodeValue; var width = widths[0].firstChild.nodeValue; var backColor = bgColors[0].firstChild.nodeValue; var border = borders[0].firstChild.nodeValue; resultText = height + " " + width + " " + backColor + " " + border; createBox(height, width, backColor, border); $('xmlResult').innerHTML = resultText; } //The xml page that is parsed. <mybox> <label> <height>100px</height> <width>300px</width> <bgcolor>#ff0000</bgcolor> <border>1px solid black</border> </label> </mybox> <html> <head> <title>AJAX Midterm</title> <script src="prototype-1.6.0.2.js" type="text/javascript"></script> <script language="JavaScript" type="text/javascript"> var boxdiv; function parseXML() { alert("parseXML Called"); } function getXML() { new Ajax.Request('description.xml', { method:'get', onSuccess: getXMLSuccess, }); } function getXMLSuccess(originalRequest) { var resultText = ""; var response = originalRequest.responseXML; var heights = response.getElementsByTagName('height'); var widths = response.getElementsByTagName('width'); var bgColors = response.getElementsByTagName('bgcolor'); var borders = response.getElementsByTagName('border'); var height = heights[0].firstChild.nodeValue; var width = widths[0].firstChild.nodeValue; var backColor = bgColors[0].firstChild.nodeValue; var border = borders[0].firstChild.nodeValue; resultText = height + " " + width + " " + backColor + " " + border; createBox(height, width, backColor, border); $('xmlResult').innerHTML = resultText; } function createBox(hei,wid,bcolor,brdr) { boxdiv = document.createElement('div'); boxdiv.style.height = hei boxdiv.style.width = wid boxdiv.style.backgroundColor = bcolor boxdiv.style.border = brdr document.body.appendChild(boxdiv); } function addText() { boxdiv.innerHTML = "<h2> My Dynamic Box </h2>"; } </script> </head> <body> <input type=button id="click" value="Click" onClick="getXML();"> <div id="xmlResult"></div> </body> </html>
  4. Is there a query that can count similar occurances. I'm trying to see how many users are registering on my site organized by timestamp. Any ideas?
  5. I would like to display data from my tables organized by date. For instance, I would like to see how many users registered today and yesterday separately. Each new user is marked with a timestamp. How do I do this?
  6. I think I answered my own question... I guess Microsoft is the only browser that recognizes the pjpeg mime type. Anyone know what the point IE was trying to make by changing the jpeg mime type to pjpeg in the first place?
  7. 1) Try: include("public_html/phptest/AbConnect.php"); Instead of: include("/public_html/phptest/AbConnect.php") 2) To go up a dirctory use ../ so if you were in the "phptest" directory and wanted to go up to the "public_html" directory you would type ../newDirectory . if you are down two directories from root and want to go back to root simply type "../../newDirectory". You can put include files anywhere, just make sure you call them with the correct path. Use "require" instead of "include" as a way of testing to see if the included file is found. If you use require, the page won't load at all and you'll know that the page you wanted to include wasn't found.
  8. I use the below code to make sure that users are using the proper format to upload pictures. Some users try to upload jpeg's and still get error's saying that their file is the wrong type. What am I missing? if (!($userfile_type == "image/pjpeg" || $userfile_type == "image/gif")) { header("Location: http://www.connectingcadence.com/process/error.php?addimgck=type"); exit; }
  9. I am using the mail() function to send an activation email to users upon registration, but hotmail keeps throwing these messages into a junk mail folder automatically. Is there a php work around for this?
  10. I've been using a single dynamic page to show content and I would prefer to use a separate page. For instance: A user submits a form with their name. Rather than displaying the name in say, the title dynamically: <title><? echo $user['name']; ?><title> I would like a new page like this: <title>John Doe</title> Can php do this?
  11. That worked perfect, but forgive me for saying I'm not sure how to replace the original table with the 'tmp' one. Anyone?
  12. How do I delete duplicate records that have unique keys? For instance, in my table there is: id | value1 | value2 | value3 1 a b c 2 a b c I want to delete record 2 (or 1). I suppose I should also mention that there are a few thousand records in the table.
  13. Use strip_tags() with exceptions. strip_tags( $_POST['variable'], '<p>' ) This will allow the user to use the <p> tag. Replace the <p> with whatever tag you don't want stripped or allow multiple tags with '<p>,<a>'. You should also notice that you don't have to include the closing tag in the exception.
  14. i have an array that I used explode() on to break it up into variables i can echo each variable by calling it with $variable[0] then $variable[1] but how do I print all of the variables without calling each one individually? i'm guessing its something like while(???some sort of code to that i don't know???) { echo $variable; }
  15. How do I make it so my page is only shown after it has been completely loaded rather than it being pieced together.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.