harmmeijer
Programmer
I display some information in an htm page witch comes from a database.
People can change pictures and text information.
When a picture is inserted witch is 400 by 100 the image is resized to fit in the screen without stretching it.
The maximum size if the image is 200 by 200 so an image of 400 by 100 is resized to 200 by 50.
When the page is loaded the function workes but the first time someone changes the picture it is not resized correctly.
document.images("lnimg".src=document.forms("myform".myfile.value
this line puts a file chosen in a form.file in a source of lnimg then the following code executes:
tmpw = document.images("lnimg".width
tmpw is not correct, it is the width of the lnimg before the source changed.
Here is where the plot thickens, if I put a message box in between the two lines it works like so:
document.images("lnimg".src=document.forms("myform".myfile.value
msgbox "some bs"
tmpw = document.images("lnimg".width
now the tmpw has the width of the lnimg (image) after the course has been changed (WHY????).
Does anybody know how to fix this client side vbscript without the msgbox?? Full code is included below:
<META name=VI60_defaultClientScript content=VBScript>
<SCRIPT ID=clientEventHandlersVBS LANGUAGE=vbscript>
<!--
Sub myfile_onpropertychange
document.images("lnimg".src=""
document.images("lnimg".src=document.forms("myform".myfile.value
msgbox "some bs"
tmpw = document.images("lnimg".width
tmph = document.images("lnimg".height
if (tmpw/tmph)=<1 then
document.images("myimg".height = 200
document.images("myimg".width = (tmpw/tmph)*200
else
document.images("myimg".width = 200
document.images("myimg".height = (tmph/tmpw)*200
end if
document.images("myimg".src = document.images("lnimg".src
document.images("lnimg".src=""
End Sub
Sub window_onload
document.images("lnimg".src = document.images("myimg".src
tmpw = document.images("lnimg".width
tmph = document.images("lnimg".height
if (tmpw/tmph)=<1 then
document.images("myimg".height = 200
document.images("myimg".width = (tmpw/tmph)*200
else
document.images("myimg".width = 200
document.images("myimg".height = (tmph/tmpw)*200
end if
document.images("lnimg".src=""
End Sub
-->
</SCRIPT>
</HEAD>
<BODY>
<form name='myform'>
<center><IMG src="C:\Mijn documenten\Mijn afbeeldingen\AAAAAAHEIGHT.jpg" name=myimg ><br></center>
<input type = file name='myfile'><br>
<input type = button name=button1><br>
<input type = button name=button2><br>
</form><IMG style="VISIBILITY: hidden" name=lnimg >
</BODY></HTML>
People can change pictures and text information.
When a picture is inserted witch is 400 by 100 the image is resized to fit in the screen without stretching it.
The maximum size if the image is 200 by 200 so an image of 400 by 100 is resized to 200 by 50.
When the page is loaded the function workes but the first time someone changes the picture it is not resized correctly.
document.images("lnimg".src=document.forms("myform".myfile.value
this line puts a file chosen in a form.file in a source of lnimg then the following code executes:
tmpw = document.images("lnimg".width
tmpw is not correct, it is the width of the lnimg before the source changed.
Here is where the plot thickens, if I put a message box in between the two lines it works like so:
document.images("lnimg".src=document.forms("myform".myfile.value
msgbox "some bs"
tmpw = document.images("lnimg".width
now the tmpw has the width of the lnimg (image) after the course has been changed (WHY????).
Does anybody know how to fix this client side vbscript without the msgbox?? Full code is included below:
<META name=VI60_defaultClientScript content=VBScript>
<SCRIPT ID=clientEventHandlersVBS LANGUAGE=vbscript>
<!--
Sub myfile_onpropertychange
document.images("lnimg".src=""
document.images("lnimg".src=document.forms("myform".myfile.value
msgbox "some bs"
tmpw = document.images("lnimg".width
tmph = document.images("lnimg".height
if (tmpw/tmph)=<1 then
document.images("myimg".height = 200
document.images("myimg".width = (tmpw/tmph)*200
else
document.images("myimg".width = 200
document.images("myimg".height = (tmph/tmpw)*200
end if
document.images("myimg".src = document.images("lnimg".src
document.images("lnimg".src=""
End Sub
Sub window_onload
document.images("lnimg".src = document.images("myimg".src
tmpw = document.images("lnimg".width
tmph = document.images("lnimg".height
if (tmpw/tmph)=<1 then
document.images("myimg".height = 200
document.images("myimg".width = (tmpw/tmph)*200
else
document.images("myimg".width = 200
document.images("myimg".height = (tmph/tmpw)*200
end if
document.images("lnimg".src=""
End Sub
-->
</SCRIPT>
</HEAD>
<BODY>
<form name='myform'>
<center><IMG src="C:\Mijn documenten\Mijn afbeeldingen\AAAAAAHEIGHT.jpg" name=myimg ><br></center>
<input type = file name='myfile'><br>
<input type = button name=button1><br>
<input type = button name=button2><br>
</form><IMG style="VISIBILITY: hidden" name=lnimg >
</BODY></HTML>