views:

15

answers:

2

Current function:

function SetPopup() {
    x$('body').setStyle('overflow', 'hidden');
    x$('#divOne').setStyle('height', document.body.offsetHeight + 'px');
    x$('#divOne').setStyle('width', 100 + '%');
    x$('#divOne').setStyle('display', 'block');
}

What I would like to do is change this function such that 'divOne' would be read-in as a parameter like this:

function SetPopup(string x) {
    x$('body').setStyle('overflow', 'hidden');
    x$('#x').setStyle('height', document.body.offsetHeight + 'px');
    x$('#x').setStyle('width', 100 + '%');
    x$('#x').setStyle('display', 'block');
}

But obviously that doesnt work.

What would I need to do to include x where I have optimistically placed it in the bottom function?

A: 

Try this:

function SetPopup(elem) {
    x$('body').setStyle('overflow', 'hidden');
    x$('#' + elem).setStyle('height', document.body.offsetHeight + 'px');
    x$('#' + elem).setStyle('width', 100 + '%');
    x$('#' + elem).setStyle('display', 'block');
}
Sarfraz
+1  A: 
function SetPopup(x) {
    x$('body').setStyle('overflow', 'hidden');
    x$('#'+x).setStyle('height', document.body.offsetHeight + 'px');
    x$('#'+x).setStyle('width', 100 + '%');
    x$('#'+x).setStyle('display', 'block');
}
Alex Reitbort