Jump to content

rollOrDie

Members
  • Posts

    31
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

rollOrDie's Achievements

Member

Member (2/5)

0

Reputation

  1. It doesn't pop up with an error message, it's just that the table just doesn't appear function tableBuild () { var container = document.getElementById ('container'); // build head var headName = document.createTextNode ('Name'); var headAge = document.createTextNode ('Age'); var th1 = document.createElement ('th'); var th2 = document.createElement ('th'); var tr = document.createElement ('tr'); var table = document.createElement ('table'); // append th1.appendChild (headName); tr.appendChild (th1); table.appendChild (tr); container.appendChild (table); alert (table.nodeName); } window.onload = tableBuild; <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> <script type="text/javascript" src="ajaxStudent.js"></script> </head> <div id="container"> This is the container </div> <body> </body> </html> It works okay in FF (surprisingly). Also, when I alert the nodeName, even IE recgnises it as a table, so I don't know why it isn't displaying it?
  2. Thanks for the help, but after hours of staring at the code, I eventually found that the error was THIS: 'ajaxCallback = displayResults;' it should have been 'ajaxCallBack', not 'ajaxCallback', there were also a couple of HTML errors in one of the pages aswell.
  3. Im trying to create a script that will edit css rules in both FF and IE, but IE just isn't having any of it! I get an error message saying that 'the object doesn't support this property or method'. Here is my code, can anybody help? var styleSheet = document.styleSheets[1]; if (styleSheet.rules) { var pAbout1 = styleSheet.rules[20].style; var pAbout2 = styleSheet.rules[22].style; var pAbout3 = styleSheet.rules[23].style; } else { var pAbout1 = styleSheet.cssRules[20].style; var pAbout2 = styleSheet.cssRules[22].style; var pAbout3 = styleSheet.cssRules[23].style; } pAbout2.setProperty ('display', 'none', ''); pAbout3.setProperty ('display', 'none', '');
  4. Im using a tutorial I have in a book to create an AJAX live search, but one of the main functions doesn't seem to be getting called! It appears that the line: ajaxCallback = displayResults; Should run the function once it is assigned using the associated code in 'ajax.js', I think? Anyway, I think that's where the code is going wrong as the function 'displayResults ()' isn't being called. It's pretty hard to tell really since no errors show up in the error console. Any help would be great! ajax.js: // AJAX library var ajaxreq = false, ajaxCallBack; function ajaxRequest (filename) { try { ajaxreq = new XMLHttpRequest (); } catch (error) { try { ajaxreq = new ActiveXObject ("Microsoft.XMLHTTP"); } catch (error) { return false; } } ajaxreq.open ("GET", filename); ajaxreq.onreadystatechange = ajaxResponse; ajaxreq.send (null); } function ajaxResponse () { if (ajaxreq.readyState != 4) { return; } if (ajaxreq.status == 200) { if (ajaxCallBack) { ajaxCallBack (); } } else { alert ('Reqeust Failed: ' + ajaxreq.statusText); } return true; } liveSearch.js: // AJAX Live Search //global time variable var time; // start timeout with each keypress function startSearch () { window.clearTimeout (time); time = window.setTimeout ('liveSearch()', 200); } // perform the search function liveSearch () { // assemble PHP filename query = document.getElementById ('searchLive').value; filename = 'search.php?query=' + query; // displayResults will handle AJAX response ajaxCallback = displayResults; // send AJAX request ajaxRequest (filename); } // display search results function displayResults () { // remove old list ul = document.getElementById ('list'); div = document.getElementById ('results'); div.removeChild (ul); // make a new list ul = document.createElement ('ul'); ul.id = 'list'; names = ajaxreq.responseXML.getElementsByTagName ('name'); for (i = 0; i < names.length; i ++) { li = document.createElement ('li'); name = names[i].firstChild.nodeValue; text = document.createTextNode (name); li.appendChild (text); ul.appendChild (li); } if (names.length == 0) { li = document.createElement ('li'); li.appendChild (document.createTextNode ('No results')); ul.appendChild (li); } // display new list div.appendChild (ul); } var input = document.getElementById ('searchLive'); input.onkeydown = startSearch; liveSearch.htm: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>AJAX Live Search</title> <script type="text/javascript" src="ajax.js"></script> </head> <body> <h1>Ajax Live Search</h1> <form id="frmSearch" name="frmSearch" method="post" action=""> <p>Search for: <input type="text" name="searchLive" id="searchLive" /> </p> <div class="results"> <ul id="results"> <li>Results will display here</li> </ul> </div> </form> <script type="text/javascript" src="liveSearch.js"></script> </body> </html>
  5. I have a result that is returned from housingDivAssign () that Im trying to assign to a variable inside the function setEvent (). However I just get the error "is not a function". Is this because Im using it inside another function? function housingDivAssign () { var housingDiv = document.getElementsByTagName ('div'); j = 0 for (i = 0; i < housingDiv.length; i ++) { if (housingDiv[i].className == 'housingHide') { var housingSection = new Array (); housingSection[j] = housingDiv[i]; alert (j + ' = ' + housingDiv[i].id); j ++; } } return housingSection; } function housingTitleAssign () { var housingTitle = document.getElementsByTagName ('span'); j = 0 for (i = 0; i < housingTitle.length; i ++) { if ((housingTitle[i].className == 'title') || (housingTitle[i].className == 'titleTop')) { var housingSectionTitle = new Array (); housingSectionTitle[j] = housingTitle[i]; // alert (j + ' = ' + housingTitle[i].id); j ++; } } return housingSectionTitle; } function setEvent () { /* for (i = 0; i < housingSectionTitle.length; i ++) { alert (housingSectionTitle[i].id); } */ var housing = housingDivAssign (); alert (housing[2].id); } setEvent ();
  6. I have a navigation list that needs to appear above a flash animation, but it doesnt seem to be working! Here is the code I have for it, <div id="headInner"> <div id="headFlash"> <object type="application/x-shockwave-flash" data="flash/bgHeadInner.swf" width="850" height="100"> <param name="movie" value="flash/bgHeadInner.swf" /> </object> </div> <ul id="nav"> <li><a href="../contact.php">contact</a></li> <li><a href="../portfolio.php">portfolio</a></li> <li><a href="../service.htm">services</a></li> <li><a href="../about.htm">about</a></li> <li><a href="../index.php">home</a></li> </ul> <br class="clear" /> </div> #nav { width:420px; position:absolute; bottom:0; right:5px; z-index:2;} #nav li { display:inline;} #nav a { width:70px; font-weight:bold; float:right; font-size:80%; margin-left:2px; padding:0 5px; color:#2597EB; text-decoration:none; background:url(../image/bgNavLi.png) no-repeat 0 100%;} #nav a:hover, #nav a:active { background:url(../image/bgNavLiHover.png) no-repeat 0 100%;} #headInner { width:850px; height:100px; margin:0 auto; text-align:left; background:url(../image/bgHeadInner.jpg) no-repeat 100% 0; position:relative;} #headFlash { width:100%; height:100px; position:absolute; z-index:1;} Does anyone know why the flash animation is still appearing above the navigation? In IE it seems to show the very bottom of the nav, but thats it! I should also point out that the page looks right in Dreamweaver, but just not in any browsers! Any help would be great! thanks.
  7. Thanks thats fixed it! Yeah I agree, its better to fix a problem than to just tell it to shut up!
  8. Ahhh I was thinking the if (!$_POST['portId']) Bit would prevent the error, looks like I was wrong. Thanks
  9. Im getting an error for a relatively simple script that basically just inserts form information into a database. I never used to have the problem, but I suppose I must have just made one small change to the script that has messed things up! Here is the error that Im getting: Here is the code near line 10 (with the if statement being line 10 itself): if ($_POST['portId']) { $portId = $_POST['portId']; } The thing is, the data still enters the database without any problems! So I think this is just a warning? But I don't see why its coming up?
  10. thanks Ill give it a try! I'd been thinking of a way to only search the div for images, I didnt know you could do it like that!
  11. Im trying to code a function that will make the value of a paragraph element equal to the title attribute of an image, whenever the image is hovered. Basically my script puts every <img> tag into an array, and checks to see if it is inside a div with the id of 'portThumbWebsite'. if it is in that div, it is supposed to make the paragraph value change so that it is the same as the image's title attribute. Instead, the onMouseOver event handler just seems to be ignored, and the paragraphs value is just set to be the same as the last index of the array of image titles. Maybe the code will help to explain! // display the name of the project on thumb hover function thumbChange (thumbTitle) { // set pWebsite equal to image title on hover pWebsite = document.getElementById ('pWebsite'); pWebsite.firstChild.nodeValue = thumbTitle; } function portTitleDisplay () { // declare variables divPortThumb = document.getElementsByTagName ('img'); thumbId = new Array (); thumbTitle = new Array (); // loop through thumb id's titles num = divPortThumb.length; // declare index to be used as array indexes index = 0; for (i = 0; i < num; i ++) { // only perform in specified div divPortThumbId = divPortThumb[i].parentNode.parentNode.parentNode.id; if (divPortThumbId == 'portThumbWebsite') { thumbId[index] = divPortThumb[i].id; thumbTitle[index] = divPortThumb[i].title; // change value of pWebsite on hover of thumb thumbId[index].onMouseOver = thumbChange (thumbTitle[index]); index ++; } } } window.onload = portTitleDisplay; Does anyone know what I might be doing wrong? There appears to be no actual errors in the syntax.
  12. Im trying to create a script that has its own built in event handlers, so that I can keep the HTML separate from the behaviour. I have to <a> tags, with separate id's, but I keep getting the 'has no properties' error message? Here is my code! // hide graphic thumbnails function hideGraphic (portThumbGraphic) { var portThumbGraphic = document.getElementById ('portThumbGraphic'); portThumbGraphic.style.display = 'none'; } // hide website thumbnails function hideWebsite (portThumbWebsite) { var portThumbWebsite = document.getElementById ('portThumbWebsite'); portThumbWebsite.style.display = 'none'; } // hide graphic thumbnails by default window.onload = hideGraphic; var btnThumbWebsite = document.getElementById ('btnThumbWebsite'); var btnThumbGraphic = document.getElementById ('btnThumbGraphic'); // set functions to nav list btnThumbWebsite.onclick = hideGraphic; btnThumbGraphic.onclick = hideWebsite; Any ideas? Thanks to anyone who can help.
  13. The box div only has a bottom margin, its the padding that has 1em all round: .box, .boxHide { border:#CCC solid 1px; background-image:url(../image/bgStripeFaint.gif); margin-bottom:1.5em; clear:both; padding:1em}
  14. Oh. maybe the following SQL query will help to explain what I need. Basically it needs to be equivalent to this: SELECT filename FROM tblPort WHERE numeric = 2 LIMIT 1 The only thing is, it needs to be executed for every numeric value [which could be anything], not just 2. Does that help?
×
×
  • 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.