Javascript help please

Soldato
Joined
10 Jun 2003
Posts
4,615
Location
New Zealand
looking for some advice if possible, I know next to nothing about js so this has got me stumped but I can't help but think there must be an answer.

The code below appears ~100 times in each page

<script type="text/javascript">
$(function() {
$('#otherdetails_247').ready(function() {
$('#otherdetails_247').height($('#wrapper_247').height());
});

$('#assingeddetails_247').ready(function() {
$('#assingeddetails_247').height($('#assignedname_247').height());
$('#assigned_247').height($('#assingeddetails_247').height());
});

});
</script>

I want to call this from an external js file but the numbers change each time, is there a way to call this whilst changing the numbers using some form of argument passed to the function?

I know that the assingeddetails is spelt wrong but I have inherited this code so can't change that easily!
 
Can we see a demo page to see it in action? It just seems like you're randomly setting the height :p.
 
the page is only available via a secure login so no can do I'm afraid :(

there are quite a few similar code fragments like this and most are just related to onscreen formatting and I don't need to change how they act. I just want to reduce the size of the page (currently over 2MB!) and I was just wondering if there was anyway that I could call with an argument of 247 which would replace xxx below.

$(function() {
$('#otherdetails_xxx').ready(function() {
$('#otherdetails_xxx').height($('#wrapper_xxx').he ight());
});

$('#assingeddetails_xxx').ready(function() {
$('#assingeddetails_xxx').height($('#assignedname_ xxx').height());
$('#assigned_xxx').height($('#assingeddetails_xxx' ).height());
});

});
 
Hmm what does it do anyway? Seems very random. And 2Mb? :eek: - if you're setting heights can't this be done with CSS?

Are you using jQuery (it looks like its syntax) or prototype or something? That might make things easier to start with.
 
from what I can get from the other people here it is used to set heights, apparently this can't be done in css correctly due to the content (how true this is I don't know).

It is using jquery yes, sorry for my lack of knowledge here, I am a js virgin!
 
from what I can get from the other people here it is used to set heights, apparently this can't be done in css correctly due to the content (how true this is I don't know).

It is using jquery yes, sorry for my lack of knowledge here, I am a js virgin!

Would personally use css for stuff like this, as if javascript isn't turned off your site could be buggered :)

I think all that is happening with $('#assingeddetails_247').height($('#assignedname_ 247').height()); is your setting a value for #assingeddetails_247 based on the height of #assignedname_ 247. Sure that could be done in css. Only reason I can think you'd use this for is to get around the min height glitch for older browsers, although youncan overcome this in css.

See http://docs.jquery.com/CSS/height

..and 2MB for a webpage!
 
Last edited:
Back
Top Bottom