PDA

View Full Version : Very Simple Question Regarding Syntax of Vars



eyalros
Apr 12th, 2007, 08:04 AM
Hello!

How (I mean, in which syntax) Can I do the following thing:


function new_Photo_Text(number) {
div[PUT HERE "NUMBER" VAR].style.height='100';
div[PUT HERE "NUMBER" VAR].style.visibility='visible';
document.all.i[PUT HERE "NUMBER" VAR].style.height='100';
i1.location='create_new/photo_text.php?block=1&page_id=<? echo $page_id; ?>&align=left';
}

Thanks!

_Aerospace_Eng_
Apr 12th, 2007, 09:27 AM
You will need to use getElementsByTagName.

function new_Photo_Text(number) {
var div = document.getElementsByTagName('div');
div[number].style.height = 100 + 'px';
div[number].style.visibility = 'visible';
// document.all.i[PUT HERE "NUMBER" VAR].style.height='100';
// i1.location='create_new/photo_text.php?block=1&page_id=<? echo $page_id; ?>&amp;align=left';
}
I commented out the last two lines because I'm not sure what type of elements those are. Besides using document.all really isn't necessary anymore and only works in select browsers like IE and Opera. I think Firefox may have support for it now as well.

glenngv
Apr 12th, 2007, 09:43 PM
I think this is what eyalros needs.

function new_Photo_Text(number) {
var div = document.getElementById("div" + number);
div.style.height='100px';
div.style.visibility='visible';
var oIframe = document.getElementById("i" + number);
oIframe.style.height='100px';
oIframe.contentWindow.location.href='create_new/photo_text.php?block=1&page_id=<? echo $page_id; ?>&align=left';
}
I'm guessing the the last element is an iframe.