Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Displaying images with correct dimensions.

Status
Not open for further replies.

gns100

Programmer
Aug 11, 2003
40
US
I'm trying to transfer the slideHeight and slideWidth info from the JS function in the switch() section to the <body> section in order to display the photos using their correct heights and widths. The slideText info works OK.

I've just displayed the key code parts to simplify the problem.

Using height=&quot;slideHeight&quot; and width=&quot;slideWidth&quot; as shown doesn't work.

Any suggestions would be helpful.
Thanks

Code:
<html>

<head>
<title>New Page 1</title>
</head>

<body>

<img border=&quot;2&quot; src=&quot;../myPhoto_1.jpg&quot; name=&quot;showPhotoRotate&quot; width=&quot;slideWidth&quot; height=&quot;slideHeight&quot; align=&quot;center&quot;></td>


      <tr>
        <td width=&quot;100%&quot; height=&quot;37&quot;><p align=&quot;center&quot;><b><font face=&quot;Arial&quot; size=&quot;3&quot;> <span id = &quot;slideText&quot;></span></font></b></td>
      </tr>

</body>

<script language=&quot;JavaScript&quot; type=&quot;text/JavaScript&quot;>
function testfn(){

var Photo=1;


	switch (Photo) {

		case 1:
			document.showPhotoRotate.src = &quot;file:///j:/myPhoto_1.jpg&quot;
			document.photoText=&quot;Photo 1&quot;
			document.getElementById(&quot;slideText&quot;).innerHTML = document.photoText
			document.photoHeight=&quot;202&quot;
			document.getElementById(&quot;slideHeight&quot;).innerHTML = document.photoHeight
			document.photoWidth=&quot;288&quot;
			document.getElementById(&quot;slideWidth&quot;).innerHTML = document.photoWidth
			
			break
		case 2:
			document.showPhotoRotate.src = &quot;file:///j:/myPhoto_2.jpg&quot;
			document.photoText=&quot;Photo 2&quot;
			document.getElementById(&quot;slideText&quot;).innerHTML = document.photoText
			document.photoHeight=&quot;279&quot;
			document.getElementById(&quot;slideHeight&quot;).innerHTML = document.photoHeight
			document.photoWidth=&quot;288&quot;
			document.getElementById(&quot;slideWidth&quot;).innerHTML = document.photoWidth
		
			break
}
</script>
</html>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top