Jump to content

jesh

Members
  • Posts

    2,293
  • Joined

  • Last visited

Everything posted by jesh

  1. I have a couple of things for you. First, every time you call your functions, you are running the same code which gets the objects from the DOM. You might consider wrapping that repetitive code in a function something like the following: var main;var mainDivs;var chart;function getObjects(){ if(!main) main = document.getElementById("chart_options"); if(!mainDivs) mainDivs = main.getElementsByTagName("img"); if(!chart) chart = main.getElementsByTagName("input");} Then, you can simply call "getObjects()" and that function will check to see if the global variables have the objects in them. If the variables don't, it will read and load them from the DOM.I've never tried making dynamic functions like you do in your for loop - this may be the cause of your problem. You might try doing something like this instead:PHP <?php$numOfCharts = count($chart);for ($i = 0, $j = 1; $i < $numOfCharts; $i++, $j++){echo '<li><img src="Images/'.$chart[$i][1].'" alt="'.$chart[$i][2].'" onclick="toggleImage(this,'.$1.');" title="Click to Select" /></li>';}?> Javascript function toggleImage(obj, idx){ switchClass( obj ); chart.value = idx; return false;}
  2. You might be looking for the optgroup tag.
  3. HTML documents are parsed by the browser from the top of the file down to the bottom of the file.Just before your <body></body> element begins, you call "loadCookie()" which, in turn, calls "currentRecord()" which attempts to use the HTML DOM (document.frm1.elements) to access a form which hasn't been rendered by the browser yet."loadCookie()" is read and processed before <form name="frm1"> so, frm1 doesn't exist when loadCookie() is called.You'll either want to call "loadCookie()" on the page load or move that function call to the bottom of the page.Example 1: <body onload="loadCookie();"> Example 2: </form><script type="text/javascript"> loadCookie();</script> </body></html>
  4. Rather than today.getmonth()today.getyear() Try: today.getMonth();today.getYear();
  5. You say you used to use HTML pages to build a form which POSTed to a PHP page. Now you need the HTML page to be a PHP page? Can't you use the HTML code and simply rename the file .php rather than .html?If not, perhaps you could post your code for the PHP page where the user inputs the information?
  6. hah! I didn't realize there was page break functionality in CSS. Does what is described on this page (http://www.w3schools.com/css/css_ref_print.asp) really work in current browsers? Anyone have any luck with it?
  7. With slightly less code, you can use: <select onchange="location.href = this.value;"> <option value="http://www.w3schools.com">W3 Schools</option> <option value="http://www.google.com">Google</option></select>
  8. That's right.I might call that function with: ajax_PostRequest("process.php", updateDisplay, "prodID=100532&userID=100542"); And my handler is something like this: function updateDisplay(){ if(http_request.readyState == 4) { if(http_request.status == 200) { var text = http_request.responseText; document.getElementById('display').innerHTML = text; } }}
  9. Here is one of my functions that sends a POST request to a URL using AJAX: function ajax_PostRequest(url, handler, data){ http_request = getHttpObject(); if(http_request) { http_request.onreadystatechange = handler; http_request.open("POST", url, true); http_request.setRequestHeader("Content-Type", "application/x-www-urlencoded"); http_request.setRequestHeader("Content-Length", data.length); http_request.setRequestHeader("Connection", "close"); http_request.send(data); }} I hope this helps!
  10. I don't know about being able to view the rendered code, but if you use Firefox, you can use its DOM Inspector (Tools -> DOM Inspector) to view the DOM for the rendered page. If your javascript added elements to the page, you wouldn't see those elements in the source, but you would be able to see them with the DOM inspector.
  11. If your div has an id: <div id="RefreshDiv"> <!-- CONTENT --></div> You can use the HTML DOM to get at the contents (and change the contents) of that div. var refreshDiv;function Refresh(content){ if(!refreshDiv) { refreshDiv = document.getElementById("RefreshDiv"); } refreshDiv.innerHTML = content;} If the "content" that you pass that function comes from the page itself, then no problem. If the "content" comes from your server, you'll have to use AJAX.
  12. jesh

    Validation

    <script type="text/javascript" src="myscript.js"></script>
  13. Generally, the code in an HTML document is parsed by the browser from the top down. Elements (like <div></div> or <a></a> or <img />) that are declared on, say, line 100 are parsed and added to the DOM before elements that are on, say, line 200.If you don't want the javascript to load until after the rest of the page loads, try putting the script down at the bottom of the page: <!-- All of your content is above here...--> <script type="text/javascript" src="myscript.js"></script> </body></html>
  14. The way you posted your sample code, if "txt_student_name.Text" is equal to "huseyin" then your query would look like this: select * from students where student_name like ' 'huseyin' %' It needs to be like: select * from students where student_name like 'huseyin%' or select * from students where student_name like '%huseyin' or select * from students where student_name like '%huseyin%'
  15. It's been a really long time since I worked with Java and Tomcat, but I seem to remember that you have to either set some CLASSPATH (different than that used with the JVM) so that Tomcat can see the jar or else put the JDBC jar in a directory where Tomcat can see it ("tomcat/lib"?).Sorry I can't be of more help.EDIT: I found this post (http://forums.mysql.com/read.php?39,23562,23562) where the user said that putting the jar in <TOMCAT_INSTALL_DIR>\common\lib solved his/her problems.Good luck!
  16. If you change your link so that it has an ID: <a id="ToggleMapLink" style="cursor: pointer;" onclick="ToggleMap();">Open</a> You can change your ToggleMap() function like so: var mapobj;var maplink;function ToggleMap(){ if(!mapobj) { mapobj = document.getElementById("Map"); } if(!maplink) { maplink = document.getElementById("ToggleMapLink"); } if(mapobj.style.display == "block") { mapobj.style.display = "none"; maplink.innerHTML = "Open"; } else { mapobj.style.display = "block"; maplink.innerHTML = "Close"; }}
  17. I think you need to change the way you are organizing the data in the XML file. Your current root node is "newdata" and you are storing the answers to the questions in "field" elements. What you are lacking here is a way to differentiate one user's data from another user's data.Either change your XML so that it is something like: <questionnaire><newdata id="cust1"> <field /></newdata><newdata id="cust2"> <field /></newdata></questionnaire> or: <newdata><userdata id="cust1"> <field /></userdata><userdata id="cust2"> <field /></userdata></newdata> Now, I don't know much about using server.CreateObject to create an XML file so I can't provide any code, but it sounds like you're going to have to read the contents of the XML file before you convert the inputs from the form into XML. Then you'll need to append the XML that is generated from the inputs to what is already loaded in your XML object. Once that is done, you can write the data to back to the file. Otherwise, you'll continue to overwrite the previous user's data.
  18. Does this link help?http://dev.mysql.com/doc/refman/5.0/en/con...-classpath.html
  19. Are you using the FileSystemObject to write your XML file?If so, you use the CreateTextFile method of the FileSystemObject and you can specify whether you overwrite previous data that is in the file or append the data to the contents of the file.The XML file will need to have a single root element - perhaps called "questionnaire" - that will contain all of your "newdata" elements. Perhaps it could look something like this: <questionnaire><newdata></newdata><newdata></newdata><newdata></newdata></questionnaire> Every time you need to write new data to the file, you could read the file contents, delete the last line of the file (the "</questionnaire>" line), append the new data to the end of the file, and then append "</questionnaire>" back to the end. That way "</questionnaire>" will always be the last line of the data and each new "newdata" element will be appended just above that closing "questionnaire" tag.
  20. If your map information is inside of a div tag, you can use HTML DOM and CSS to hide/display that div tag when you click on the link. The code could look something like this:HTML <a style="cursor: pointer;" onclick="ToggleMap();">Click here</a><div id="Map"> <!-- CONTENT GOES HERE --></div> CSS #Map { display: none; } Javascript var mapobj;function ToggleMap(){ if(!mapobj) { mapobj = document.getElementById("Map"); } if(mapobj.style.display == "block") { mapobj.style.display = "none"; } else { mapobj.style.display = "block"; }}
  21. Crazy, I had no idea. This runs fine in Firefox: <script type="text/javascript">function test(){ test2 = "variable declared without var.";}test();document.write(test2 + "<br />");</script>
  22. jesh

    CSS Woes

    The image doesn't flicker, but the cursor flickers from the pointer to the pointer/hourglass. Why do people still use IE?
  23. <body onload="disp_confirm();"> This will pop up the confirmation when the page first loads.
  24. jesh

    CSS Woes

    Thanks for the help everyone! I'm making this .NET page that is one of the more complicated forms I've built to date (having to do with file management and assigning certain files to folders and blah blah blah) and this wasn't something I could afford to spend hours on.This is what I used (thanks aspnetguy): <div style="width: 95%; margin: auto;"><div style="float:left; width: 45%;">Folders</div><div style="float:right; width: 45%; text-align: right;">[Add - Edit]</div><br style="clear: both;" /></div> Incidentally, I did find a neat way to do mouseovers:HTML: <a class="mousy" href="#"><img src="images/clear.gif" width="24" height="24" alt="" />Some text goes here</a> CSS: a.mousy img { background-image: url(images/folder_closed.gif); }a.mousy:hover img { background-image: url(images/folder_open.gif); }
  25. A better way might be to look at the onfocus and onblur events. You could use the onfocus event to check the value of the field to see if it is the default value that you specified. If it is, you could then clear it to make room for the user input. If it is not, you could ignore it so that it doesn't clear out what the user may have already written.You could then use the onblur event to check the value of the field to see that there is something written in it. If it is empty, you could insert your default text.
×
×
  • Create New...