User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the HTML and CSS section within the Web Development category of DaniWeb, a massive community of 425,777 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,345 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our HTML and CSS advertiser: Lunarpages Web Hosting
Views: 1131 | Replies: 4 | Solved
Reply
Join Date: Apr 2008
Posts: 4
Reputation: Mapper99 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Mapper99 Mapper99 is offline Offline
Newbie Poster

Input box not accepting focus...

  #1  
Jun 5th, 2008
For some reason when I click on my simple input box, the input box does not accept focus. Has anyone seen this before? Here is a link to the webpage:

www laudontech com / garmin

Here is my code:

  1. <form name="form1" method="POST" action="test5.php5">
  2. </br>
  3. <P ALIGN=CENTER>
  4. <INPUT TYPE = "TEXT" VALUE ="Enter a search term" NAME="SearchItem" ID="SearchItem" onfocus="clearDefault(this)" onclick="set_focus()" >
  5. <INPUT TYPE = "Submit" Name = "Submit1" VALUE = "Find">

Thanks in advance,

Mapper
Last edited by peter_budo : Jun 8th, 2008 at 5:55 am. Reason: Keep It Organized - please use [code] tags
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Sep 2006
Location: San Diego, CA USA
Posts: 99
Reputation: M_K_Higa is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 2
M_K_Higa's Avatar
M_K_Higa M_K_Higa is offline Offline
Junior Poster in Training

Re: Input box not accepting focus...

  #2  
Jun 5th, 2008
Are you trying to clear the text box when it gets focus? if so, the see the code below. (I'm not too sure what you wanted to get out of the onclick event.)

  1. <html>
  2. <title>test</title>
  3. <script type="text/javascript"> <!--
  4. function clearDefault(arg) {
  5. //alert("Test");
  6. arg.value="";
  7. }
  8. // -->
  9. </script>
  10. </head>
  11. <body>
  12. <form name="form1" method="POST" action="#">
  13. <input type="text" value="Enter a search term" name="SearchItem" id="SearchItem" onfocus="clearDefault(this)" />
  14. <input type="Submit" Name = "Submit1" value="Find" />
  15. </form>
  16. </body>
  17. </html>
-Mike
Reply With Quote  
Join Date: Apr 2008
Posts: 4
Reputation: Mapper99 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Mapper99 Mapper99 is offline Offline
Newbie Poster

Re: Input box not accepting focus...

  #3  
Jun 5th, 2008
Thanks for the reply Mike. All I am trying to do is get the input box to start editing if I place my cursor in it. The only way I can enter data into the box is to use tab to highlight it first. If I click in the input box when there is text in it, I can edit. When the inputbox has no text, I can't make it editable by clicking in it. Hope I haven't confused the heck out of you. Try the webpage and observe the strange behaviour.

Thanks!
Reply With Quote  
Join Date: Sep 2006
Location: San Diego, CA USA
Posts: 99
Reputation: M_K_Higa is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 2
M_K_Higa's Avatar
M_K_Higa M_K_Higa is offline Offline
Junior Poster in Training

Re: Input box not accepting focus...

  #4  
Jun 5th, 2008
Here's your code...

  1. <body bgcolor="#000000" onload="load()" onunload="GUnload()">
  2.  
  3. <div id="" align="center">
  4. <a href="http://www.laudontech.com"><img alt="logo" src="http://www.laudontech.com/Images/LaudontechLogoSmall.png" border="0"></a>
  5. </div>
  6.  
  7. <div id="A" style="width: 640; position: absolute; left: 50%; margin-left: -300px;" >
  8. <h3><font color="#FF8080" face="trebuchet ms" ><center>Garmin Office Plans via Google Maps</center></h3>
  9. </font>
  10. </br>
  11. </div>
  12. <form name="form1" method="POST" action="test5.php5">
  13. </br>
  14. <P ALIGN=CENTER>
  15. <INPUT TYPE = "TEXT" VALUE ="" NAME="SearchItem" ID="SearchItem">
  16. <INPUT TYPE = "Submit" Name = "Submit1" VALUE = "Find">
  17. <br>
  18. </P>
  19. </form>

Your <div id="A" ...> tag is interfering with your text box. i.e., it overlaps the text box.

To see what I mean, try coloring the background of the div tag with a color other than black.

Here's what I did to expose the problem...

<div id="A" style="background-color: silver; width: 640; position: absolute; left: 50%; margin-left: -300px;" >
You can probably fix this by changing your code to something like this...

<div id="A" align="center" style="background-color: silver;>
or even getting rid of the div, font and center tag and doing something like this...

<h3 style="color: #FF8080; font-face: trebuchet ms; text-align: center;">Garmin Office Plans via Google Maps</h3>
Hope this helps. Here's the final code.... (up to the closing </form> tag)

  1. <html xml:lang="en" lang="en">
  2. <head>
  3.  
  4. <title>Test</title>
  5. <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
  6.  
  7. </head>
  8.  
  9.  
  10. <body bgcolor="#000000" onload="load()" onunload="GUnload()">
  11.  
  12. <div id="" align="center">
  13. <a href="http://www.laudontech.com"><img alt="logo" src="http://www.laudontech.com/Images/LaudontechLogoSmall.png" border="0"></a>
  14. </div>
  15.  
  16. <h3 style="color: #FF8080; font-face: trebuchet ms; text-align: center;">Garmin Office Plans via Google Maps</h3>
  17.  
  18.  
  19. <form name="form1" method="POST" action="test5.php5">
  20. </br>
  21. <P ALIGN=CENTER>
  22. <INPUT TYPE = "TEXT" VALUE ="" NAME="SearchItem" ID="SearchItem">
  23. <INPUT TYPE = "Submit" Name = "Submit1" VALUE = "Find">
  24.  
  25. <br>
  26.  
  27.  
  28.  
  29. </P>
  30. </form>
-Mike
Reply With Quote  
Join Date: Apr 2008
Posts: 4
Reputation: Mapper99 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Mapper99 Mapper99 is offline Offline
Newbie Poster

Re: Input box not accepting focus...

  #5  
Jun 5th, 2008
Thanks, works like a charm! nice tip for debugging as well.

M
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb HTML and CSS Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Other Threads in the HTML and CSS Forum

All times are GMT -4. The time now is 2:52 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC