DarkendSoul Posted September 22, 2006 Share Posted September 22, 2006 Currently im using the following script in an attemp to preview local images before submitting them but it doesnt change...[code] <tr><td class="text">Image:</td> <td><img id="icon" class="world"> <input type="hidden" name="MAX_FILE_SIZE" value="5000" /><input type="file" name="char_pic" size="15" class="char_pic" onclick="icon.src = 'file:///' + this.value" /></td></tr>[/code]does anyone know why? the file exists... Quote Link to comment Share on other sites More sharing options...
michaellunsford Posted September 23, 2006 Share Posted September 23, 2006 hey, cool. it works.problem is the onClick. Clicking the button opens the browse window while the javascript attempts to load an unselected image to the image source. After you select a picture, click it again and the image pops right up.maybe onclick isn't the right way to do this? maybe a <body onFocus> or something? Quote Link to comment Share on other sites More sharing options...
DarkendSoul Posted September 24, 2006 Author Share Posted September 24, 2006 hrm body focus doesnt work out for me just due to the theme script which goes basicly like...<html><body>{MAIN}</body></html>where {MAIN} is it loads all the info into. so yeah... accessing body easily doesnt work very well. ;)i changed it to onChange... doesnt work Quote Link to comment Share on other sites More sharing options...
DarkendSoul Posted September 24, 2006 Author Share Posted September 24, 2006 Also note this is a firefox only website... x.x just so you know. Quote Link to comment Share on other sites More sharing options...
michaellunsford Posted September 24, 2006 Share Posted September 24, 2006 What about a setInterval that checks this.value for a value every three or five seconds. Onclick starts the setInterval, and the function called by setInterval will assign the image source and unset the interval upon finding a value? Quote Link to comment Share on other sites More sharing options...
DarkendSoul Posted September 24, 2006 Author Share Posted September 24, 2006 Never heard of or used setInterval, could you give me an example? Quote Link to comment Share on other sites More sharing options...
michaellunsford Posted September 24, 2006 Share Posted September 24, 2006 [code=php:0]var my_var = setInterval("somefunction",5000);[/code]That would fire the function every five seconds.http://developer.mozilla.org/en/docs/DOM:window.setIntervalhttp://developer.mozilla.org/en/docs/DOM:window.clearInterval[b]PS>[/b] it is case sensitive and firefox is very very case sensitive. Also, the quotes aren't listed in the manuel, however, I found that firefox wouldn't work without quoting the function to call. Quote Link to comment Share on other sites More sharing options...
fenway Posted September 25, 2006 Share Posted September 25, 2006 You should probably be using the onchange handler, not onclick. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.