Jump to content


Photo

Preview local images


  • Please log in to reply
7 replies to this topic

#1 DarkendSoul

DarkendSoul
  • Members
  • PipPipPip
  • Advanced Member
  • 121 posts

Posted 22 September 2006 - 11:55 PM

Currently im using the following script in an attemp to preview local images before submitting them but it doesnt change...

         <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>

does anyone know why? the file exists...

#2 michaellunsford

michaellunsford
  • Members
  • PipPipPip
  • Advanced Member
  • 1,023 posts
  • LocationLouisiana, USA

Posted 23 September 2006 - 03:39 AM

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?

#3 DarkendSoul

DarkendSoul
  • Members
  • PipPipPip
  • Advanced Member
  • 121 posts

Posted 24 September 2006 - 08:27 PM

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

#4 DarkendSoul

DarkendSoul
  • Members
  • PipPipPip
  • Advanced Member
  • 121 posts

Posted 24 September 2006 - 08:33 PM

Also note this is a firefox only website... x.x just so you know.

#5 michaellunsford

michaellunsford
  • Members
  • PipPipPip
  • Advanced Member
  • 1,023 posts
  • LocationLouisiana, USA

Posted 24 September 2006 - 08:47 PM

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?

#6 DarkendSoul

DarkendSoul
  • Members
  • PipPipPip
  • Advanced Member
  • 121 posts

Posted 24 September 2006 - 08:51 PM

Never heard of or used setInterval, could you give me an example?

#7 michaellunsford

michaellunsford
  • Members
  • PipPipPip
  • Advanced Member
  • 1,023 posts
  • LocationLouisiana, USA

Posted 24 September 2006 - 09:02 PM

var my_var = setInterval("somefunction",5000);

That would fire the function every five seconds.

http://developer.moz...dow.setInterval
http://developer.moz...w.clearInterval

PS> 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.

#8 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 25 September 2006 - 04:06 AM

You should probably be using the onchange handler, not onclick.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users