vikas_maderna
asked on
Problem in Script which can resize the picture at load time
hello Experts
This is my code
<script language=vbscript>
function ChangeHeight(oh,ow,nh,imgn m)
nw= (nh*ow)/oh
alert(nw)
end function
</script>
<td><P align=center><A href="http://www.artageindia.com/bigpic.asp?id1=36"> <IMG id="img1"
src="products1_files/BC-01 1.jpg" border=2 onload="ChangeHeight(this. height,thi s.width,77 ,this.id)" > </p></td>
<td><P align=center><A href="http://www.artageindia.com/bigpic.asp?id1=37"> <IMG id="img2"
src="products1_files/BC-01 2.jpg" border=2 onload="ChangeHeight(this. height,thi s.width,77 ,this.id)" > </p></td>
<td><P align=center><A href="http://www.artageindia.com/bigpic.asp?id1=38"> <IMG id="img3"
src="products1_files/BC-01 3.jpg" border=2 onload="ChangeHeight(this. height,thi s.width,77 ,this.id)" > </p></td>
now i want to change the width and height of the below images (img1,img2,img3) so that all the pictures height remain same and width can be changed accordingly using function. Now using function how to change the size of pictures run time.
thanks
vikas
This is my code
<script language=vbscript>
function ChangeHeight(oh,ow,nh,imgn
nw= (nh*ow)/oh
alert(nw)
end function
</script>
<td><P align=center><A href="http://www.artageindia.com/bigpic.asp?id1=36"> <IMG id="img1"
src="products1_files/BC-01
<td><P align=center><A href="http://www.artageindia.com/bigpic.asp?id1=37"> <IMG id="img2"
src="products1_files/BC-01
<td><P align=center><A href="http://www.artageindia.com/bigpic.asp?id1=38"> <IMG id="img3"
src="products1_files/BC-01
now i want to change the width and height of the below images (img1,img2,img3) so that all the pictures height remain same and width can be changed accordingly using function. Now using function how to change the size of pictures run time.
thanks
vikas
ASKER
hello ,
In this function
function FixImages() {
ChangeHeight('img1', 77);
ChangeHeight('img2', 77);
ChangeHeight('img3', 77);
}
You have made the img1 and img2, .... name fixed while for me this is variable thing, as it is asp page and pictures are comming from database and i dont know their numbers. Then how can i do this.
thanks
vikas
In this function
function FixImages() {
ChangeHeight('img1', 77);
ChangeHeight('img2', 77);
ChangeHeight('img3', 77);
}
You have made the img1 and img2, .... name fixed while for me this is variable thing, as it is asp page and pictures are comming from database and i dont know their numbers. Then how can i do this.
thanks
vikas
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Also, I used Math.round so you don't get non int width.
Here it is:
--------------------------
<HTML>
<HEAD>
<script language="javascript">
function ChangeHeight(ImgId, nh) {
var ImgObj = document.getElementById(Im
ImgObj.width = Math.round((nh*ImgObj.widt
}
function FixImages() {
ChangeHeight('img1', 77);
ChangeHeight('img2', 77);
ChangeHeight('img3', 77);
}
</script>
</HEAD>
<BODY onload="FixImages()">
<table><tr>
<td><P align=center><A href="http://www.artageindia.com/bigpic.asp?id1=36"> <IMG id="img1"
src="products1_files/BC-01
<td><P align=center><A href="http://www.artageindia.com/bigpic.asp?id1=37"> <IMG id="img2"
src="products1_files/BC-01
<td><P align=center><A href="http://www.artageindia.com/bigpic.asp?id1=38"> <IMG id="img3"
src="products1_files/BC-01
</tr></table>
</BODY>
</HTML>
--------------------------