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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display a texbox 1

Status
Not open for further replies.

rac55

Programmer
Jul 1, 2003
62
AU
Hi

Does anyone know the how to display a hidden textbox using the javascript onclick event ona html button?

Thanks
Rachel
 
Hi

Thanks for your reply.

I have been using style=display:none on the textbox.
When a user clicks on the button to display the textbox to goes to the function. It keeps returning that the textBoxName is undefined

Any ideas?

Thanks

 
you need to replace textBoxName with the name of your textbox :D
 
Hi

I have changed the name..but it still keeps returning undefined

Thanks
Rachel
 
try using document.textBoxName or if the textbox is in a form use document.forms[0].textBoxName
 
Sorry I have tired it both ways but returns is null or not an object. The code is

<form name="frmNoOrder" action="" method="post">
<input type="button" name="No" value="No" class="selstyle" onclick="javascript:WrongDetails();" >
</form>

<form name="frmFindEmployee" action="FindEmployee.asp" method="post">
<%if Request.ServerVariables("REQUEST_METHOD") = "POST" then %>
<input type=text name="txtLogin" style=display:none value="txtLogin">
</form>

Javascript;

function WrongDetails(){

document.forms[0].txtLogin.style.visibility="visible";
document.frmNoOrder.submit();
}

Thanks for your help
Rachel
 
Modify your WrongDetails function to read:

Code:
function WrongDetails(){
    document.forms['frmFindEmployee'].txtLogin.style.visibility = 'visible';
    document.frmNoOrder.submit();
}

Hope this helps,
Dan
 

Actually, this would be better:

function WrongDetails(){
document.forms['frmFindEmployee'].txtLogin.style.visibility = 'visible';
document.forms['frmNoOrder'].submit();
}

;o)

Dan
 
use:
Code:
<script language="Javascript">
function WrongDetails(){
    document.forms["frmFindEmployee"].txtLogin.style.display = "block";
    document.forms["frmFindEmployee"].txtLogin.style.visibility = "visible";
    document.frmNoOrder.submit();
}
</script>

but of what I see, once you make it visible, you submit the form therefore you don't get to see it visible because the new page is loading...
 
Hi

Thanks very much its now not returning any errors. However it is still not appearing..I take it style=display:none is incorrect.

Thanks
Rachel
 

Aaah - I should have read the post more clearly. This should work:

Code:
function WrongDetails(){
    document.forms['frmFindEmployee'].txtLogin.style.display = 'block';
    document.forms['frmNoOrder'].submit();
}

Hope this helps,
Dan
 
Thanks thats very helpful but now it appears when the button is clicked..but does not stay on the screen

Any ideas

Thanks for your help

Rachel
 

Modify this line:

Code:
<input type="button" name="No" value="No" class="selstyle" onclick="javascript:WrongDetails();" >

to read this:

Code:
<input type="button" name="No" value="No" class="selstyle" onclick="WrongDetails(); return(false);">

Hope this helps,
Dan
 
it doesn't stay there because you immediatelly submit the form after you set it to visible... I already told you that in a post previousely!
 
Thanks for all your help, its really appreciated. Is there anyway to overcome this issue? I have treid to return(false); but it doesn't amke a difference

Thanks
 
tell us what you want your page to do, because i'm pretty cnfused. you want to have that field visible only if the details are correct? how do you want to verify the details? (server side?)
 
I just need a textbox and button to display when a user clicks on the buton 'no', which it is doing at the moment apart from disappearing.

No I don't need to evrify any details

Thanks
 
then simply remove the "document.forms['frmNoOrder'].submit();" part.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top