Jump to content

IAmBill

Members
  • Content Count

    12
  • Joined

  • Last visited

Community Reputation

0 Neutral

About IAmBill

  • Rank
    Newbie
  1. Ah, I found the answer, the problem was that there were an implicit conversion of float to string on the assignment to opacity.So:opacity = 0 = "0"opacity += 0.1 = "00.1" = "0.1"opacity += 0.1 = "0.10.1" = invalid dataMakes sense... sorry for the stupid question.
  2. Unfortunately, I'm running this locally on WAMP server. You can however test it in any one of W3schools Tryit Editor pages by using this code below.<html><body><script type="text/javascript">function flash(obj) { if (flash.called) { if (flash.obj.style.opacity == 1) { flash.called = false; } else { flash.obj.style.opacity += 0.1; setTimeout("flash()", 1); } } else { flash.called = true; flash.obj = obj; flash.obj.style.opacity = 0; setTimeout("flash()", 1); }}</script><span style="border:1px solid black" onclick="flash(this)">CLICK ME TO FLASH!</span></body></html> The flash function is simply supposed to make an element blink from completely transparent to full opacity over the course of a second. The function works just fine other than that fact that, for some reason, the increment statement doesn't seem to be incrementing past the value of the right-side argument.
  3. function flash(obj) { if (flash.called) { if (flash.obj.style.opacity == 1) { flash.called = false; } else { flash.obj.style.opacity += 0.01; setTimeout("flash()", 1); } } else { flash.called = true; flash.obj = obj; flash.obj.style.opacity = 0; setTimeout("flash()", 1); }} Granted it's late at night and I'm tired, but I can't for the life of me figure out why this function doesn't work. I removed the debug messages, but the basic gist is this... the statement "flash.obj.style.opacity += 0.01;" only works once... that is to say, the function is called with an object. It goes to the first else, sets the internal variable to the parameter object, the opacity is sucessfully set to 0, and the timeout is set. The timeout happens, the first condition succeeds, it goes to the second else, opacity is successfully incremented to 0.01. The timeout is set again, it happens again, goes the second else, again... now, at this point, if checked the opacity is still 0.01 before the call, so all of the variables remained intact between calls. This time, however, after the statement "flash.obj.style.opacity += 0.01;" the opacity is still 0.01 rather than 0.02 as it should be. I mean, I literally have these alerts in the function: alert("Before: " + flash.obj.className + " - " + flash.obj.style.opacity);flash.obj.style.opacity = flash.obj.style.opacity + 0.1;alert("After: " + flash.obj.className + " - " + flash.obj.style.opacity); ...and they tell me the opacity is 0.01 in both of them. What's the deal? Why would the increment statement work on the first call but not on subsequent calls?
  4. Thank you, justsomeguy.Submit to itself... it's so obvious that I can't believe I didn't think of it myself. Regardless, that link provides tons of tips that I definitely wasn't doing properly. Thanks again for everything.
  5. Hi, I'm trying to create a very simple registration form. Nothing fancy, just a log-in, password, email address, and a couple of confirmations. While I have it set up in AJAX to alert the user if they're using a log-in or email address already in the database, I have to tend to those than don't support AJAX and redirect back to the registration page if they try to submit a registration with errors.So, the checks are easy enough... I don't have problems identifying whether or not they've made a bad registration. The issue is that I don't know the proper way to redirect the user back to the registration form if it's invalid. If I use the header() function it clears the text fields which I don't want. The second alternative is to write out the submission page as a form that writes out all of the fields with their values, then submits itself to the registration form which will then fill in the fields if the $REQUESTs are available. This seems... less than elegant, though.There are millions of registration forms all of the internet... It's a pretty common thing, which is why I'd like to do it correctly. Could anyone endulge me on what the server-side scripts look like on a registration submission?
  6. Hmmm... you're getting me thinking, but I'm on the day after an all-nighter, so I'm probably not thinking clearly. I know I couldn't possibly have larger tables than some of the more major websites... and it's sensible to break the data up into two tables that cross-reference each other based on comparable keys... in fact, it feels obvious, but my brain is liquid so I can't quite comprehend it. In fact, I'm quite sure I've done plenty of it in a previous database I've built for a company... maybe I should sleep.
  7. I don't know this particular paradigm of web development and I was hoping some more experienced developers could help me on this one. I am not posting this in a medium specific forum as I'm uncertain which medium to use.Let's say I have a registration-based website with the potential for a large amount of traffic. Now, let's say I have functionality in the website where I users are able to write personal notes on any other user which they can recall at a later time. Given the fact that there is a cross-reference of users, the number of possible combination grows exponentially with each new user. What is the best way to store this? Would it be best to just throw it into a single table in a database with three fields and just let it get massive? Do mySQL tables have row restrictions? Would it be better to give each user their own table? What about storing the data in unique XML files for the user? I could see having thousands of tables in a database being an issue, but would it be absurd to have thousands of XML files stored? I'm just concerned that if I lump it into one table that it might take a while to query it. I think it would be less time consuming to maintain a reference table of users to their respective XML file, and just parse that to get the info I need.
  8. Hi, I have a need to get the pixel values of CSS properties that were never used-defined or are set to auto. That is to say... if I never defined a height for a span element, it would be defaulted to auto, and if I were to set a background color, I can distinctly see what the height of the span element is. I'd like to know the pixel value of this height as determined by the browser. Is this possible?Thanks.EDIT: I suppose the same query would refer to properties set to "inherit," though I don't explicitly have a use for that at this time. Regardless, I believe it would fall into the same solution for those browsing this post with a similar query.
  9. Hi, I have a bit of a situation which I'm too tired to wrap my brain around... normally I would just go to sleep and think of it in the morning, but it's eating me up and I can't sleep until I get the answer.So anyway, I have reassigned document.onmousemove to a specific function. Let's say for debug purposes that this function simply updates a <span> with the coordinates of the mouse. Now, as I move the mouse around, I can see the coordinates changing in the span.The next step was to have an onmouseover event on a specific image object. The goal was to have the image's opacity come in when I hover over the object. The problem is, when I set the event property, while it's triggering (when I'm moving the mouse over the image) document.onmousemove does not trigger. This is a problem for my functionality.Now, I can think of one fairly hackish solution to this... but I'd rather avoid it and I'm hoping that there is a way to get the browser to listen for both events simultaneously. Alternatively, the hacking solution would be to calculate the global mouse coordinates inside of the object.onmouseover function by setting it to the objects top and left positions plus it's relative position inside of the image. ... again, if possible though, I'd like it to try and listen for both events, instead.Thanks.
  10. Thanks... I figured as much, I just needed to be certain.EDIT: Ah, but it seems each element maintains its ID regardless of whether it can be referenced by the DOM. I believe this means I could use it for something like this:function zoom(){ var aspectRatio = parseFloat(document.getElementById("myImage").style.height) / parseFloat(document.getElementById("myImage").style.width); var imageList = document.getElementsByTagName("img"); for (var x in imageList) { if (imageList[x].id == "myImage") { imageList[x].style.height = (parseFloat(imageList[x].style.height) + 2) + "%"; imageList[x].style.width = (parseFloat(imageList[x].style.width) + (2 * aspectRatio)) + "%"; } }} Seem alright?
  11. Hi, I have a page with a series of images with the same style. The size of the images is dynamically applied to the images with PHP and I'd like the user to be able to scale these at their choosing with a couple of buttons. The issue, however, is that for some reason the simple javascript that I thought would work doesn't... I set all of the images to have the same Id and assumed that by using getElementById and adjusting the style it would affect all of the images... unfortunately, it only affects the first image. Anyone have any idea of what's going on? function zoom(){var aspectRatio;aspectRatio = parseFloat(document.getElementById("myImage").style.height) / parseFloat(document.getElementById("myImage").style.width);document.getElementById("myImage").style.height = (parseFloat(document.getElementById("myImage").style.height) + 2) + "%";document.getElementById("myImage").style.width = (parseFloat(document.getElementById("myImage").style.width) + (2 * aspectRatio)) + "%";} ... and if I had these two images below, only the first would be adjusted... I'd like all to be adjusted... <img src='images/card_green.gif' style='position:absolute; left:0%; width:12.25%; top:0%; height:13.78%;border:none;padding:none;' id='myImage' /><img src='images/card_green.gif' style='position:absolute; left:0%; width:12.25%; top:0%; height:13.78%;border:none;padding:none;' id='myImage' />
×
×
  • Create New...