JS questions

Discussion in 'JavaScript' started by HorrorMovies, Apr 28, 2010.

  1. #1
    I know Js but I dont know it well enough to actually sit and code with out help yet...

    1. Is there away using JS to an images dimensions before the upload? as I need to validate the image dimensions for images before the actual upload begins as it would save the user a lot of time.

    2. How do I create a JS feature that will watch for when a form is submitted? - for example I want to load a loading image into the page when the form is submitted.

    Any help is appreciated!
     
    HorrorMovies, Apr 28, 2010 IP
  2. dimitar christoff

    dimitar christoff Active Member

    Messages:
    882
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    90
    #2
    1. not via js but there are flash-helpers that worth WITH javascript that do allow for verification. one such is http://digitarald.de/project/fancyupload/ - Fancy Upload (through mootools framework). look for other 'flash uploaders'. there was also talk on improving file uploads through html5 but I am not sure how far along that got, plus allowing a user to check file sizes or dimensions through pure javascript will be too much of a security risk.
    2. yes. basically through vanilla js you handle the submit event. eg.

    
    document.getElementById("formid").onsubmit = function(e) {
        // create a new image element and do something
        alert("doing something");
    };
    
    Code (javascript):
    example that works: http://www.jsfiddle.net/KpsbT/1/

    i'd recommend using a framework though
     
    dimitar christoff, Apr 29, 2010 IP
  3. zerophean

    zerophean Peon

    Messages:
    91
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hi, you could using javascript framework,

    I suggest using jQuery
     
    zerophean, May 1, 2010 IP
  4. starx

    starx Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    suggest jQuery.
    very easy and very beautifull
     
    starx, May 4, 2010 IP