Jump to content

jesh

Members
  • Posts

    2,293
  • Joined

  • Last visited

Everything posted by jesh

  1. Without actually building it myself, I'm guessing it wouldn't be too complicated. I would suggest moving the part of the script that hides all open sub menus into its own function: function hideSubMenus(){ var spans = document.getElementsByTagName("span"); for(var i = 0; i < spans.length; i++) { if(spans[i].className == "hide") spans[i].style.display = "none"; }}function hideshow(which){ // call the hideSubMenus() function to hide all the // open menus: hideSubMenus(); if (!document.getElementById) return; if (which.style.display != "inline") which.style.display = "inline";} Then, you could have hideSubMenus() be the event listener for the click event of the radio buttons in the sub menu: <input type="radio" onclick="hideSubMenus();" /> You might have to tweak it here and there to get it to work exactly how you wanted, but it should put you in the right direction.EDIT: Hmm, I seemed to have read your post too quickly. The above still sort of applies, however. Separate out the code into those two functions. Then, on radio buttons that have sub menus, use the hideshow() function. On radio buttons that don't have sub menus, use the hideSubMenus() button. Hope this helps!
  2. jesh

    Testing for IE :p

    I typically try to code for the W3C standards and throw in extras to include the IE users (though day by day, I'm less inclined to include them ): function handleClick(e){ e = (e) ? e : window.event; var target = (e.target) ? e.target : e.srcElement; // target now has the element that sent the event // regardless of whether the browser is IE, Firefox, Opera, etc.}
  3. I'm also a C# developer. http://www.codeproject.com/csharp/ has some good tutorials/articles as well.
  4. Usually, the best bet is to use relative paths. Put all of your code and images in a single directory - for example c:\folder. Then, put all of your images in a images directory - c:\folder\images. Then, in your code, you can reference the images with "images/image1.jpg".Otherwise, you'll need to use absolute paths with file:/// in front of it and the slashes facing the other direction in the rest of the path. For example: file:///c:/folder/file.jpgI hope this helps!
  5. You were close! It's document.getElementById rather than document.GetElementById.
  6. Since you named your class "hide" rather than "SubContent", and since you are using a span rather than a div to hold that content, you'll need to make a few changes to that script.First, you'll need to getElementsByTagName("span") rather than getElementsByTagName("div"), and second, you'll want to look for the spans that have a className of "hide" rather than "SubContent". Here's the updated script:function hideshow(which){ if (!document.getElementById) return; var spans = document.getElementsByTagName("span"); for(var i = 0; i < spans.length; i++) { if(spans[i].className == "hide") spans[i].style.display = "none"; } if (which.style.display != "inline") which.style.display = "inline";}
  7. Quite honestly, in my experience, certificates are not worth as much as experience. If you are strapped for time and need to make a decision today, I would recommend having your company simply pay for you to take a javascript class at either the local university or a local community college. While you will not get a certificate for completing a course there, you would, at least, get educated and gain some experience which you could then go out and design/build more sites for a portfolio.For example, I have a degree in Comparative Religion (not Computer Science) and I don't have a single certificate to my name, but what I lack in pieces of paper, I have in my 10 years of experience writing code. And I guarantee that an employer would rather see 10 years experience (or at least see some samples of work that has been done) than see a number of certificates.Just my opinion.
  8. I believe what justsomeguy is getting at is that it is much easier to have a single page (called something like news.php) to which you pass a particular id and that page displays the appropriate news article. The URL, rather than being "4.php" would be "news.php?id=4". Or, using mod_rewrite (as justsomeguy also mentioned), the URL could be something like "news/4". However, in both of these cases, there would only need to be one file that would get its contents from the database depending on which news ID you passed to it.I hope this helps.
  9. I believe I read that specification differently than you because I don't think it's possible to do what you are saying:<html><head><style>p.test { background-color: red; }</style></head><body><p.test>This paragraph will <b>not</b> have a red background.</p><p class="test">This paragraph will have a red background.</p></body></html>
  10. You might try checking to see what type of input an element is and decide how to validate based on that. For example, rather than just getting the value: var s = eval('document.' + FormName + '.' + FieldList[i] + '.value'); You might try getting the actual element, checking it's type, and then continuing on: var element = eval('document.' + FormName + '.' + FieldList[i]);if(element.type == "text"){ // this is a text input...strip the spaces and check for length}else if(element.type == "radio"){ // this is a radio button, validate it depending on your needs}
  11. So you only want one radio button's sub content to be visible at a time? The way I generally get around this is to put the sub content in containers that have the same class: <div id="SomeID" class="SubContent"><!-- Content goes here --></div> Then, in the hideshow function, I would get all div elements and loop through them. Any div that had a className of "SubContent" I would hide. Something like this: function hideshow(which){ if (!document.getElementById) return; var divs = document.getElementsByTagName("div"); for(var i = 0; i < divs.length; i++) { if(divs[i].className == "SubContent") divs[i].style.display = "none"; } if (which.style.display != "block") which.style.display = "block";}
  12. It looks like the problem is the document.innerHTML call. It appears that there isn't a innerHTML property of the document object. Rather than: var newtext = newwindow.document.innerHTML; You might try: var newtext = newwindow.document.body.innerHTML; This will get you the contents of the body element on your child window.However, depending on your requirements, you can cheat a little and use something like this: function createNewDoc(){ var newwindow=window.open(); var txt="<html><body>Learning about the DOM is FUN!</body></html>"; newwindow.document.write(txt);// Since we are writing the HTML to the child window within this function, we // know what content is going to be written there so we'll just use the// value that is in the txt variable.var newtext = txt;document.getElementById("field").value = newtext; } One final piece of advice, rather than simply writing to the document in the child window, you'll be better off if you open the document, write to it, and then close it. Like this: newwindow.document.open();newwindow.document.write(txt);newwindow.document.close(); I hope this helps!
  13. How about using non-breaking space characters? Also, pre-CSS, people used to use transparent images to make whitespaces.
  14. jesh

    Invalid characters

    You might also think about learning regular expressions: if(preg_match("/^[A-Z0-9_]+$/", $_POST['username']){ // username is ok}else{ // username has invalid characters.} This site has a good tutorial: http://www.regular-expressions.info/tutorial.html
  15. You could use CSS: <head><style type="text/css">td.wide { width: 75%; }td.narrow { width: 25%; }</style></head><body><table> <tr> <td class="wide"> </td> <td class="narrow"> </td> </tr></table></body> Or, you could look into using the colgroup and col tags. http://www.w3schools.com/tags/tag_colgroup.asp
  16. Yeah, the syntax can be anything, it just depends on the application that uses it. You could write a tool that looks for {} or one that looks for () or && or ##, [], ``.It may just be that the developer of that page/site decided to use {}.
  17. jesh

    Content-Type problem

    The way I got around this in ASP.NET (not classic ASP) was to have the client send the request to a page on my server. Then, on that page, the server would send the request to the other server (FedEx in your case) and get the response back. I would then capture all the text in the response from the other server. Finally, I would set the response from my server to the client as "text/xml" and write all the text to the response.I hope this helps.
  18. As your code stands, there would be no parent window. Try this instead: function createNewDoc(){ var newwindow=window.open(); var txt="<html><body>Learning about the DOM is FUN!</body></html>"; newwindow.document.write(txt); var newtext = newwindow.document.innerHTML; document.getElementById("field").value = newtext;} Also, it appears that there is a typo in the input on the page: <input type " "text" id = "field"> Should be: <input type = "text" id = "field">
  19. If you are using Firefox, I recently became aware of a great extension called Firebug. It's become an indispensable tool for when I develop and debug web sites and web applications. I'd highly recommend it.https://addons.mozilla.org/firefox/1843/
  20. This might get you started, Sniffy: http://www.regular-expressions.info/java.html
  21. Paint.NET is another decent image editor and it's getting better and better with each release - and it's free.http://www.getpaint.net/index2.html
  22. Sounds like a perfect situation for AJAX. Using AJAX, you can load the XML file and parse through it using the XML DOM.Run through the AJAX tutorial to get started. My only recommendations are that, on this part of the tutorial, rather than using:xmlHttp.responseText; Use, unless you are parsing through the XML file server-side: xmlHttp.responseXML; Also, rather than setting the URL to some ASP, PHP, ASPX, etc. file, set the URL to your XML file.
  23. jesh

    ASP.NET Strings

    I wasn't aware that you could pass the delimiter as a char rather than a char array. In Visual Studio, when I type ".Sp" after a string variable, intellisense pops up to tell me that Split is a valid method with 6 variations - each of which only accept char[] or string[] rather than char or string. So I've just been passing it as an array. :)The MSDN site says to pass it as an array too:http://msdn2.microsoft.com/en-us/library/s...ring.split.aspxHeck, if Split('\\') works, I'll use it!
×
×
  • Create New...