Scriptbanger
Joined: 23 Aug 2006 Posts: 5 Location: Boise, Idaho
|
Posted: Wed Aug 23, 2006 10:52 pm Post subject: Need help with visibility attribute |
|
|
Okay, here's the deal. I have a form and a select box where a user will select how many fields they want. All I would like to do is "make visible" the number of fields they select. I am at a total loss as to how to do this. Any help would be greatly appreciated.
Here is a simple cut 'n' paste page markup to see what I have so far. I think it'll be pretty obvious that the 'showEm()' function is completely screwed up.
| Code: |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Test Page</title>
<script language="JavaScript" type="text/javascript">
<!--
var num = document.form1.numberselect.options[document.form1.numberselect.selectedIndex].value;
function showEm(num){
if (document.getElementById("text")) >= num{
document.getElementById("text").style.visibility = "hidden";
} else {
document.getElementById("text").style.visibility = "visible";
}
}
function makePage() {
var text1 = document.form1.f1.value;
var text2 = document.form1.f2.value;
var text3 = document.form1.f3.value;
var text4 = document.form1.f4.value;
var text5 = document.form1.f5.value;
document.open();
document.write("<html>\n<head>\n<title>Array</title>\n\n");
document.write("</head>\n\n");
document.write("<body leftmargin=\"0\" topmargin=\"0\">\n\n<center>\n");
if (text1 != ""){
document.write(text1 + " - ");
}
if (text2 != ""){
document.write(text2 + " - ");
}
if (text3 != ""){
document.write(text3 + " - ");
}
if (text4 != ""){
document.write(text4 + " - ");
}
if (text5 != ""){
document.write(text5);
}
document.write("</body>\n</html>\n");
document.close();
}
//-->
</script>
</head>
<body onload="showEm(document.form1.numberselect.options[document.form1.numberselect.selectedIndex].value);">
<form name="form1" id="form1">
How many fields do you want?
<select name="numberselect" id="numberselect" onchange="showEm(document.form1.numberselect.options[document.form1.numberselect.selectedIndex].value);">
<option value="1">1
<option value="2">2
<option value="3" SELECTED>3
<option value="4">4
<option value="5">5
</select>
<br>
<input type="text" name="f1" id="f1"><br>
<input type="text" name="f2" id="f2"><br>
<input type="text" name="f3" id="f3"><br>
<input type="text" name="f4" id="f4"><br>
<input type="text" name="f5" id="f5"><br>
<br>
<input type="button" value="Make It!" onclick="javascript:makePage();">
</form>
</body>
</html>
|
Thanks- |
|