Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

script for making form elements invisble or visible

Status
Not open for further replies.

buzzybee

Programmer
May 23, 2001
17
US
What i need to do is make a second form invisble until the first form has been submitted
i have this in my head
<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
<!-- Begin
document.form2.txtyes.style.visibility = 'hidden'
document.form2.txtno.style.visibility = 'hidden'
// End -->
</script>
then this in my submit for the first form
onclick=&quot;document.form2.txtyes.style.visibility = 'visible'&quot;

here is the code for the form:
<b><p>Did the letters print to your satisfaction?</b>
<p>
<form action=&quot;/SpInet/spinet.spi?wwSpinet~letterchk&quot; method=&quot;POST&quot; name=&quot;form2&quot;>
<input type=&quot;Submit&quot; name=&quot;txtyes&quot; value=&quot;Yes&quot;>
<input type=&quot;Submit&quot; name=&quot;txtno&quot; value=&quot;No&quot;>
</form><p>


this isn't working, it says document.form2.txtyes is not an object...
I know this is not right,but I am not familiar with javascript
can anyone help me fix this?

Amanda
 
Hmmm... I don't see how that will work, unless your form has a javascript action or other action that will not load a new page. Otherwise, once you submit one form, the page will be gone. jared@eae.net -
 
the page stays once the form is submitted.
that is the way i designed it.
I have it built in where the first form submit button will gray out when it is clicked. But the second form on the page needs to be grayed out UNTIl the top form submit is clicked.
 
why submit? use simple button!
& put these buttons into span or div:

var NC=(document.layers)?true:false
function setVis(obj,v){
var oobject
if (document.all){ oobject=eval('document.all.'+obj+'.style') }
else if (document.layers){ oobject=eval('document.layers.'+obj) }
oobject.visibility=(v)?(NC?&quot;show&quot;:&quot;visible&quot;):(NC?&quot;hide&quot;:&quot;hidden&quot;)
}

and then in body

<form name=myne>
<input type=button value='make visible' onclick=&quot;setVis('tata',true)&quot;>
<input type=button value='make invisible' onclick=&quot;setVis('tata',false)&quot;>
<span id=tata style=&quot;position:absolute&quot;>
<input type=button value='appearing' onclick=&quot;&quot;>
</span>
</form>


for any of these buttons u culd add onclick=&quot;document.forms.myne.submit()&quot; thus makin it submit button
regards, vic
 
but notice that in nn every layer has its own document object; so, if u'll put just a button here - there wuld be nothing.
hang on a second, i'll fix it...
 
ok, think i did it...
here u are:
function:

var NC=(document.layers)?true:false
function setVis(v){
var oobject
if (document.all){ oobject=document.all.l3.style;}
else if (document.layers){
oobject=document.layers.l1;
}
oobject.visibility=(v)?(NC?&quot;show&quot;:&quot;visible&quot;):(NC?&quot;hide&quot;:&quot;hidden&quot;)
}

& ur form:

<form>
<input type=button value='make visible' onclick=&quot;setVis(true)&quot;>
<input type=button value='make invisible' onclick=&quot;setVis(false)&quot;><br>
<ilayer id='l1' ><layer id='l2' ><div id=l3 style='position:relative'><form name=newf><input type=button value='appearing' onclick=&quot;&quot;></form></div></layer></ilayer>
</form>


now it works in nn4.6 too, but my dreamweaver says that there is something wrong with nested form tags - well, at least, it works...

regards, vic
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top