Jump to content

jesh

Members
  • Posts

    2,293
  • Joined

  • Last visited

Everything posted by jesh

  1. I don't think you need AJAX for this unless there is some data on the server that you need in order to validate the file. Javascript alone should suffice.What about using the focus and blur events on the inputs?1) Regarding switching the background color: First, set up all required fields so that the background color is yellow. Then, do something like this to make the field change from yellow to white when the user puts focus on the field and back to yellow if s/he leaves the field without typing in any data: <input type="test" id="UserName" onfocus="this.style.backgroundColor = 'white';" onblur="validate(this);" /> function validate(element){ if(element.value == "") { element.style.backgroundColor = "yellow"; }} 2) and 3) I'm not really sure where you're going with this. Should the error message show up before the user even begins entering data into the form? Should it only show up if the user clicks the submit button? Or when focus is given to the field? If it is when focus is given to the field, you could do something like this: <span id="UserNameError" style="display: none;">This field is required.</span><input type="test" class="required" id="UserName" onfocus="enteredField(this);" onblur="validate(this);" /> function enteredField(element){ if(element.className == "required") { element.style.backgroundColor = "white"; var span = document.getElementById(element.id + "Error"); if(span) { span.style.display = "inline"; } }}function validate(element){ if(element.value == "") { element.style.backgroundColor = "yellow"; var span = document.getElementById(element.id + "Error"); if(span) { span.style.display = "none"; } }}
  2. jesh

    cookies

    You can use cookie-less Sessions. This is where a unique identifier is encoded into the URL of the request so that the server can associate the visitor with that visitor's session. Depending on the implementation, the URLs can come out pretty ugly:e.g. http://www.mysite.com/3432ec7b66ffa2390af7c73d/index.html
  3. Yer kidding me. IE7 doesn't support <br style="clear: left;" />? What else are they willy-nilly going to attempt to change?
  4. I tried to post this yesterday but the session timed out. (What's with this site being so slow sometimes???).Anyhow, in addition to the link above, you can check here as well:http://www.quirksmode.org/dom/changess.html
  5. jesh

    Event.KeyCode

    hah. I knew that, I must have not been thinking. Thanks!
  6. What if you set up your form something like this: <form id="LoginForm" onsubmit="return validate();"><span id="UserNameError" style="display: none;">required</span><input type="text" id="UserName" onkeydown="hide('UserNameError');" /><br /><span id="PasswordError" style="display: none;">required</span><input type="password" id="Password" onkeydown="hide('PasswordError');" /><input type="submit" value="submit" /></form> Then had javascript like this: function hide(elementID){ var element = document.getElementById(elementID); if(element) { element.style.display = "none"; }}function validate(){ var isValid = true; if(document.getElementById("UserName").value == "") { document.getElementById("UserNameError").style.display = "inline"; isValid = false; } if(document.getElementById("Password").value == "") { document.getElementById("PasswordError").style.display = "inline"; isValid = false; } return isValid;}
  7. jesh

    mysql security

    You typically create one user so that your webserver can connect to the database. You don't need to create a separate database user for each user of your website. You only need the one user for the webserver.
  8. I use them sometimes so that I can more easily get at the elements with CSS without setting a class:thead th, thead td { font-weight: bold; text-align: center; }
  9. jesh

    Event.KeyCode

    Is this only for Windows Forms? Or does this work on Web Forms as well?
  10. If your iframes had IDs of "LeftFrame" and "RightFrame" like so: <html><head><script type="text/javascript">function go(leftURL, rightURL){ // First, let's get references to the iframes on the page. var leftFrame = document.getElementById("LeftFrame"); var rightFrame = document.getElementById("RightFrame"); // Next, let's see if we found the LeftFrame if(leftFrame) { // We found it, let's set the src for the frame (so the page will load) leftFrame.src = leftURL; } // Next, let's see if we found the RightFrame if(rightFrame) { // We found it, let's set the src for this frame (so the page will load) rightFrame.src = rightURL; }}</script></head><body><iframe id="LeftFrame"></iframe><iframe id="RightFrame"></iframe><a href="events.html" onclick="go('events.html', 'calendar.html'); return false;">Calendar</a></body></html>
  11. jesh

    Expandable Block

    Is this page on the Internet? If so, maybe you could provide a link and it'd be easier to determine what the problem is.
  12. Try doing a match for anything that isn't a letter: var regex = /[^a-zA-Z]/g;if(document.asform.value.match(regex)){ alert("Please enter only letters."); document.asform.author.value=""; document.asform.author.focus(); return false;}else{ return true;}
  13. All of the links are relative to whichever folder the HTML file is in because, I'm assuming, you are creating the links in the javascript with something like this: var link = document.createElement("a");link.href = "somepage.html"; So, when you are in the root directory and you create a link on your page, it'll link to "somepage.html". When you are in a sub-directory, say, "images/", the link will link to "somepage.html" which will be in the "images/" directory.To get around this, you can make all of your links relative to the root directory like this: var link = document.createElement("a");link.href = "/somepage.html"; Notice the forward slash at the beginning. This tells the browser/webserver that all links should be relative to the root directory. Then, no matter from which directory your HTML file calls the javascript, all the links will be relative to the root directory.
  14. If javascript is enabled in the browser, this'll work:<a href="#" onclick="return false;">Clicking on this does nothing.</a>
  15. I don't know anything about: But it has been my experience that it is not possible to view any of the details (i.e. dimensions of an image, file size, last modified date) of a file that resides on a client computer using javascript. My guess is that you'll have to allow the file to be uploaded to the server and have your server-side code view the details of the file and then decide whether the file matches your criteria or not.
  16. jesh

    cookies

    I think the functions shown in the javascript tutorial are pretty decent. If those don't work for you, you might try this page for more info:http://www.quirksmode.org/js/cookies.html
  17. It should work, yes, but it doesn't in IE6.
  18. In C# it'd be: foreach(Student student in studentInfo){ ...} So I'm guessing that in VB it'd be: For Each student As Student In studentInfo...Next
  19. There's a small overview/tutorial here but, unfortunately, it's all in VB:http://www.w3schools.com/aspnet/default.aspYou can find a number of great articles over at codeproject:http://www.codeproject.com/aspnet/I think your best bet would be to start working on a project and then asking a forum (like this one) when you get stuck on something specific.Good luck!
  20. I think you may want to go back and re-read this post in its entirety. As far as I can tell, boen_robot has only offered you answers to your questions - including an answer on how to get your images (twice).
  21. You generally want to avoid using the same variable (e.g. inherit) for different things in your code. Also, I don't think you need the nested loops. You might try changing it to something like this: function setTo(element, fontSize){ // Set the font-size. element.style.fontSize = fontSize; // Get all the child nodes for this element. var children = element.childNodes; // Loop through all the child nodes, one at a time. for(var i = 0; i < children.length; i++) { // Let's add a check to verify that the node is an // element rather than something like a text node. if(children[i].nodeType == 1) { // We found an element in the children array. // Let's recursively call the setTo function on this // element. setTo(children[i], fontSize); } }}
  22. First thing I notice is that the "page_request" is declared locally in your ajaxpage function and is inaccessible in your callback function ("loadpage()"). Try creating a global variable called page_request instead: var bustcachevar=1var loadedobjects=""var rootdomain="http://"+window.location.hostnamevar bustcacheparameter=""var page_requestfunction ajaxpage(url, containerid){page_request = false.... Second thing, what exactly is your if statement in the callback function ("loadpage()") trying to do? The logic is that if the readyState is 4 (i.e. "complete") and either the response status is 200 (i.e. "OK") or the URL in the address bar doesn't have "http" in it?I would suggest changing it to: if (page_request.readyState == 4){ if(page_request.status == 200) { // request came back OK, refresh the content } else { // there was some type of error. }}
  23. This might get you started:http://www.wikipedia.org/wiki/XSSIf you can't do it with javascript alone (as I expect), you'll probably have to create a server-side solution where your client-side code can send a request (in the same domain) as your server and your server code would fetch the web service and return it to the client.
  24. That's going to all be javascript and CSS. <html><head><style>#MyForm { position: absolute; top: 300px; left: 300px; }</style><script>function moveit(){ var form = document.getElementById("MyForm"); var _top = form.offsetTop; var _left = form.offsetLeft; form.style.top = (_top + Math.random()*100) + "px"; form.style.left = (_left + Math.random()*100) + "px";}</script><body><form id="MyForm"> <input type="submit" onmouseover="moveit();" value="Submit" /></form></body></html> Of course, this example only moves the form down and to the right. But you could introduce another variable (or two) that is randomly 1 or -1 to determine which direction to move the form.Hope this helps.
  25. jesh

    Textarea - add text

    Hmm, I don't know how to return the caret position in IE, but this works to insert data at the caret position (whatever that may be) in IE and Firefox:<html><body><textarea id="myTextarea"></textarea><button onclick="newcontent();">New Content</button><script>function newcontent(){ var textarea = document.getElementById("myTextarea"); if(document.selection) // IE Code { textarea.focus(); var range = document.selection.createRange(); range.text = "NEW CONTENT"; } else // DOM Code { var pos = textarea.selectionStart; var beginText = textarea.value.substring(0, pos); var endText = textarea.value.substr(pos); textarea.value = beginText + "NEW CONTENT" + endText; }}</script></body></html>
×
×
  • Create New...