Click to See Complete Forum and Search --> : Help with script


mike_basil
04-09-2003, 01:46 PM
If you can't tell I am new at using JavaScript. Can someone lead me in the right direction with this script? I am trying to display these links if the name is equal to a specific value. Sorry for the hassle and thanks in advance.

function getLinks(status){

var my_array = new Array();
if(status == "JOHN SMITH"){
<a href = "Link1.html">Link 1</a>
<a href = "Link2.html">Link 2</a>
<a href = "Link3.html">Link 3</a>

my_array[0] = document.anchors("Link 1");
my_array[1] = document.anchors("Link 2");
my_array[2] = document.anchors("Link 3");
}
for (i = 0; i < my_array.length; i++) {
document.write(my_array[i]);
}
}
}

requestcode
04-09-2003, 02:27 PM
You might try this:
var my_array = new Array();
function getLinks(status){
var my_array = new Array();
if(status == "JOHN SMITH"){
my_array[0]='<a href = "Link1.html">Link 1</a>'
my_array[1]='<a href = "Link2.html">Link 2</a>'
my_array[23='<a href = "Link1.html">Link 3</a>'
}
for (i = 0; i < my_array.length; i++) {
document.write(my_array[i]);
}
}
}