Placing a picture in a table

Hi there, <br />
<br />
I've a problem. I want to display an image (uploaded by a user into a database) within certain borderlimits, to be specific 300x240. The image can have diffrent dimensions but it should be displayed within an area with the size of 300x240. That is not much of a problem, <br />
what you do is this: <br />
<br />
<img src=http://www.htmlforums.com/archive/index.php/"picture.jpg" height="240" width="300"> <br />
<br />
However when the picture has different dimensions say 100x500, the picture will be all messed up. <br />
My question now is, how can I prevent this? My guess was using a 1 cell table. But it doesn't work in the way I thought was most logical, like this: <br />
<br />
<table border="1"> <br />
<tr height="240"> <br />
<td width="300"><img src=http://www.htmlforums.com/archive/index.php/"picture.jpg" height="100%" width="100%"> <br />
</td> <br />
</tr> <br />
</table> <br />
<br />
Does anybody know how to handle? I've tried much different things but they all just do'nt seem to work. Or is what I want not possible in HTML?<br />
<br />
Tnx, <br />
Jos<!--content-->It's no possible with HTML, you'll need to use java-script for that, you'll have to detect the image size, if it is bigger than 300x240 you resize to 300x240 but if it is smaller you will just load it as is, do a search for some java-script examples... jaeman<br />
<br />
<br />
Site 1 (<!-- m --><a class="postlink" href="http://www.js-examples.com/js/">http://www.js-examples.com/js/</a><!-- m -->) <br />
<br />
Site 2 (<!-- m --><a class="postlink" href="http://www.planet-source-code.com/">http://www.planet-source-code.com/</a><!-- m -->) <br />
<br />
Site 3 (<!-- m --><a class="postlink" href="http://www.hotscripts.com/">http://www.hotscripts.com/</a><!-- m -->)<!--content-->Tnx, I'll try out some scripting<br />
<br />
Tnx for the links, I should get there now. :)<!--content-->I'll try an write you out the script, see how you go though, jave-script is a great language to learn, It can do so much more with your HTML, Not to hard to understand either... jaeman;)<!--content-->I'm not the greatest @ js but the attachment in the previous reply will do what you need, I just did it quickly so if anyone can improve on it please do for jduke's sake & for my sanity... jaeman:rolleyes:<br />
<br />
Ps, post the HTML doc if you need help adding the script to your document... jae<!--content-->Wow, superb! Tnx for the efford. :)<br />
<br />
I've been trying something too. It doesn't work yet and basically i'm changing a script made for something else.<br />
I'll try out your script next monday. My workday is over Let the weekend begin ;)<br />
<br />
Implementing the script shouldn't be a problem.<br />
<br />
I'll let you know what I did!<br />
<br />
Good weekend,<br />
<br />
Jos<!--content-->I'm a bit suspicious of your script, jaeman. Or is this what you intended to do, it shows the image only when you click on a link?<!--content-->agent002<br />
I'm a bit suspicious of your script, jaeman. Or is this what you intended to do, it shows the image only when you click on a link? <br />
<br />
Well the links were only an example to show how the script functions, you could have it check onload, activate the script from within a cell, there is no limit to how you activate the script other than the boundarys of javascript source code & your abilitys... jaeman<!--content-->You're right, I just noticed that jduke actually said 'Implementing the script shouldn't be a problem'.<!--content-->Hi again.<br />
<br />
Well I succeeded making a script which does the thing I want. It is slightly different than the script you provided, jaeman. Still you gave me some insight and now it works fine.<br />
<br />
Tnx for the help.<br />
<br />
The attachment shows the script I made.<!--content-->
 
Back
Top