|
I would like to be able to delete certain elements (selectively) from the form elements array (using an onchange handler). This goes further simply disabling an element ... I`d like to simply make it go away!
Any ideas?
|
|
|
So for example, if you have a form with three text inputs, you`d like to have the ability to make one no longer exist. Well, I assume you want this to fire upon a particular event. Without doing complete page rewrites with JavaScript--which can be done, one way would be to have the page submit back to your ASP server on that event and rewrite the page back minus the form element. When you say you want it to no longer exist, are you sure that having it disabled and invisible would not be good enough? A DISABLED form element will not even show up in your Form.Request collection -- so server-side, it does not exist anymore. So now you have the problem of making it invisible to the user--this is fairly simple using styles. The code below shows an example of both disabling and making invisible a complete form element. For all practical purposes, it does not exist. Is this good enough for what you need?
(Don`t forget to fix the single ticks when you copy & paste code from the forum.)
----------------------------
<script language=javascript1.2>
function HideField(fName) {
o = document.forms[0].elements[fName];
o.disabled = true;
styleName = `s` + fName;
o = document.getElementById(styleName);
o.style.display = `none`;
}
function ShowField(fName) {
styleName = `s` + fName;
o = document.getElementById(styleName);
o.style.display = `inline`;
o = document.forms[0].elements[fName];
o.disabled = false;
}
</script>
<form>
<span id=stext1 style="display:inline"><br>Field 1: <input type=text name=text1></span>
<span id="stext2" style="display:inline"><br>Field 2: <input type=text name=text2></span>
<span id="stext3" style="display:inline"><br>Field 3: <input type=text name=text3></span>
<br><input type=button value="Make Field 2 Disappear" onclick="HideField(`text2`)">
<br><input type=button value="Make Field 2 Re-Appear" onclick="ShowField(`text2`)">
</form>
|
|
|
|
|
Um...in my previous post, "Form.Request collection" should be "Request.Form collection". oops.
|
|
|
|
|
|
|
|
|
|