PDA

View Full Version : how do you get to a div tag with a variable being the name


kwhubby
11-07-2002, 07:49 AM
how do you get to a div tag with a variable being the name. Here is an example, were the purple is wrong and were I need help
<script>
var x = prompt("which div ","")
var q = document.getElementById[x].properties
.....
</script>
<body>
<div id="zxcv" style="..."></div>
<div id="asdf" style="..."></div>
<div id="fdsa" style="..."></div>

glenngv
11-07-2002, 07:59 AM
var x = prompt("which div ","");
var q = document.getElementById(x);
if (q){//means valid object
alert(q.id);
}



of course you can execute it only after the div has loaded

kwhubby
11-07-2002, 08:43 PM
thanks for your help, Ill try fixing it later today when I have time