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

A simple strip for showing a text box not works 1

Status
Not open for further replies.

kjaletyu

Programmer
Feb 5, 2006
12
GB
Hi,

I have just learnt this from here and tried the following code without success:

<script>
function ShowBox()
{
document.getElementByld('boxID').style.display='inline';
}
</script>

<button onclick="javascript:ShowBox()">Show Box</button>
<input id="boxID" style="display:none">
 
Thank you.

The code is all I am testing in a file T.html.

The error message is
Line: 3
Error: Object doesn't support this property of method
 
Can anybody test the above code and tell me if you got error message or was just fine?
 
Maybe it's the fact you're using the wrong method name - "getElementBy[!]l[/!]d" should be "getElementBy[!]I[/!]d" (you have a lowercase "L", when you need an uppercase "I".

Dan



[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
BillyRayPreachersSon,

You are right. I had checked the letters one by one for a few times. I just cannot believe!!!

Thank you.

And thanks a lot for all the helps from all of you.
 
You might want to set instant focus on the text box so that the client can start typing into it straight away, other than the button keeping the focus and the client having to click on the text box, ie,

Code:
<html>
<head>
</head>
<body>
<script>
function ShowBox(){
var x = document.getElementById('boxID');
x.style.display='inline';
x.focus();
}
</script>
<input type="button" onclick="ShowBox();" value="Show Box" />
<input type="text" id="boxID" style="display:none" />
</body>
</html>

should do it, still it's you call, just a suggestion.
 
Fendal,

Thank you. Your suggestion makes my code nicer :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top