hey everyone im new to this site and javascript. i really need help coz ill go blind soon for researching
what im trying to accomplish is simple but i couldnt.. i have a set of images with the id 'resizing' its in the middle row of a 3 row table. top and bottom rows have fixed heights.
now i need a script that will calculate the window height and resize the height of images with the id 'resizing' to 70% of window height.. here is what ive written but it doesnt work and i call that function on body onload.. should i call it on img onload once ive got a working script?
well ive done it may way coz i want the script to affect only the elements with the id 'resizing'... thanks a lot ill try ur suggestion and report back
nope... didnt work.. look here is the link of the site http://www.erkutacar.com/senol/beauty.php and u already know the scriptcode.. (image the borders visible to see whats going on :] )
I don't think you understand what was suggested and why.
Code:
var img = document.getElementById('resizing');
var image_height = document.getElementById('resizing').height; // this is not needed
Code:
var image_height = img.height; // this is what you need.
the object image when accessing a property of that object like img.height is only the same as saying document.getElementById('resizing').height;
We all have baggage to carry in life, unfortunately for me I always get the trolley with the wonky wheel...
Code:
Youre = {
STILL_not_getting_it:function(){
alert("YOU, the original poster / thread starter NEED to POST the code and NOT a LINK.");
},
MissingThePoint:function(msg){
alert("You're missing the point. " + msg);
}
}
Youre.STILL_not_getting_it();
The point I am making is that you already have "Grabbed" an instance of the object, pointless duplication of an objects information.
We all have baggage to carry in life, unfortunately for me I always get the trolley with the wonky wheel...
Code:
Youre = {
STILL_not_getting_it:function(){
alert("YOU, the original poster / thread starter NEED to POST the code and NOT a LINK.");
},
MissingThePoint:function(msg){
alert("You're missing the point. " + msg);
}
}
Youre.STILL_not_getting_it();
You can only refer to ONE id as ALL ID's have to be UNIQUE
It is NAME tags in elements that can share, your alternative would be to use the getElementsByClass workaround and give only those elements you want changes a class name and an empty entry in the css table.
We all have baggage to carry in life, unfortunately for me I always get the trolley with the wonky wheel...
Code:
Youre = {
STILL_not_getting_it:function(){
alert("YOU, the original poster / thread starter NEED to POST the code and NOT a LINK.");
},
MissingThePoint:function(msg){
alert("You're missing the point. " + msg);
}
}
Youre.STILL_not_getting_it();
1. your posting only your script.
2. we have no HTML to associate with your function.
3. we have no way of knowing how you have implemented your script and code.
4. its img.height not image.height
Code:
function resize_images()
{
var img = document.getElementById('resizing');
var window_height = document.body.clientHeight;
var image_height = image.height; // <---- Pardon me!
if(image_height == window_height / 100 * 70);
{
img.height = window_height / 100 * 70;
}
}
So please post your HTML so we can see what it is thats causing the function to not work in addition to the changes in the code as indicated.
We all have baggage to carry in life, unfortunately for me I always get the trolley with the wonky wheel...
Code:
Youre = {
STILL_not_getting_it:function(){
alert("YOU, the original poster / thread starter NEED to POST the code and NOT a LINK.");
},
MissingThePoint:function(msg){
alert("You're missing the point. " + msg);
}
}
Youre.STILL_not_getting_it();
oh damn it worked then i changed image for img but only for the first pic.. as u mentioned every object should have a unique id.. so would giving a class name instead of id work?
here is my html: (i posted the link of the page so u could see the code but i guess u didnt bother)
is easier to read and open your strings and close string with " first and inner quotes of ' and where you need to have a value, as illustrated, the $num is replaced directly with $files[$i]
Then when you got your PHP pumping out code correctly, you can then worry about the javascript as its pointless dealing with that until the underlying HTML is working or properly formatted.
We all have baggage to carry in life, unfortunately for me I always get the trolley with the wonky wheel...
Code:
Youre = {
STILL_not_getting_it:function(){
alert("YOU, the original poster / thread starter NEED to POST the code and NOT a LINK.");
},
MissingThePoint:function(msg){
alert("You're missing the point. " + msg);
}
}
Youre.STILL_not_getting_it();
ClassName nor Name worked.. but ById worked (only for the first img) and what u said about php stopped my script it was working fine the original way..
Search the internet for the function getElementByClass and also the getElementByName
With the "Class" you use this with an empty stylesheet entyr, call it imagesize, then you apply the class="imagesize" to the <img tag you generate, then the getElementByClass will pull all elements with the class name of "imagesize" ready for your script to manipulate.
With the getElementsByName will pull all elements by the name tag.
Again, we have no script to see how you implemented the changes, so its stabbing in the dark time again, talking of which, I have been up since 4am and its coming up to midnight and I am offski to bedski.
I suggest that you understand how to use these functions and the importance of getting your HTML output error free first then worry about the javascript.
You have herd of the term / expression "Running before you can walk", well this is just that scenario, your transfixed by the javascript end of the programming which is pointless unless you have the underlying HTML sorted out.
We all have baggage to carry in life, unfortunately for me I always get the trolley with the wonky wheel...
Code:
Youre = {
STILL_not_getting_it:function(){
alert("YOU, the original poster / thread starter NEED to POST the code and NOT a LINK.");
},
MissingThePoint:function(msg){
alert("You're missing the point. " + msg);
}
}
Youre.STILL_not_getting_it();
thnx a lot for the effort man.. ive also tried document.getElementById('gallery').getElementsByName('resizing'); but didnt work. i havent made any other changes to the html and it doesnt have any errors.. i validated it... sleep well
Bookmarks