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:

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

Thanks in advance,

Mapper

Recommended Answers

All 5 Replies

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.)

<html>
<title>test</title>
<script type="text/javascript"> <!--
function clearDefault(arg) {
	//alert("Test");
	arg.value="";
}
// -->
</script>
</head>
<body>
<form name="form1" method="POST" action="#">
<input type="text" value="Enter a search term" name="SearchItem" id="SearchItem" onfocus="clearDefault(this)" />
<input type="Submit" Name = "Submit1" value="Find" />
</form>
</body>
</html>

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!

Here's your code...

<body bgcolor="#000000" onload="load()" onunload="GUnload()"> 

<div id="" align="center">
    <a href="http://www.laudontech.com"><img alt="logo" src="http://www.laudontech.com/Images/LaudontechLogoSmall.png" border="0"></a>
</div>

<div id="A" style="width: 640; position: absolute; left: 50%; margin-left: -300px;"  >
<h3><font color="#FF8080" face="trebuchet ms" ><center>Garmin Office Plans via Google Maps</center></h3>
</font>
</br>
</div>
<form name="form1" method="POST" action="test5.php5">
</br> 
<P ALIGN=CENTER>
<INPUT TYPE = "TEXT" VALUE ="" NAME="SearchItem" ID="SearchItem">
<INPUT TYPE = "Submit" Name = "Submit1" VALUE = "Find">
<br>  
</P>
</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)

<html xml:lang="en" lang="en">
<head>

  <title>Test</title>
  <meta http-equiv="content-type" content="text/html; charset=utf-8"/>

</head>


<body bgcolor="#000000" onload="load()" onunload="GUnload()"> 

<div id="" align="center">
    <a href="http://www.laudontech.com"><img alt="logo" src="http://www.laudontech.com/Images/LaudontechLogoSmall.png" border="0"></a>
</div>

<h3 style="color: #FF8080; font-face: trebuchet ms; text-align: center;">Garmin Office Plans via Google Maps</h3>


<form name="form1" method="POST" action="test5.php5">
</br> 
<P ALIGN=CENTER>
<INPUT TYPE = "TEXT" VALUE ="" NAME="SearchItem" ID="SearchItem">
<INPUT TYPE = "Submit" Name = "Submit1" VALUE = "Find">

<br>  



</P>
</form>

Thanks, works like a charm! nice tip for debugging as well.

M

Hello,

This is an old thread but I have the same issue but I don't know how to fix it with my code:

<div class="agent_contanct_form ">
    <?php    
     if ( basename(get_page_template())!='contact_page.php') { ?>
             <h4 id="show_contact"><?php _e('Contact Me', 'wpestate'); ?></h4>
     <?php 
           }else{
     ?>
             <h4 id="show_contact"><?php _e('Contact Us', 'wpestate'); ?></h4>
     <?php } ?>

    <?php if ( ($contact_form_7_agent =='' && basename(get_page_template())!='contact_page.php') || ( $contact_form_7_contact=='' && basename(get_page_template())=='contact_page.php')  ){ ?>

        <div class="alert-box error">
          <div class="alert-message" id="alert-agent-contact"></div>
        </div> 

        <input name="contact_name" id="agent_contact_name" type="text"  placeholder="<?php _e('Your Name', 'wpestate'); ?>" 
               aria-required="true" class="form-control">
        <input type="text" name="email" class="form-control" id="agent_user_email" aria-required="true" placeholder="<?php _e('Your Email', 'wpestate'); ?>" >
        <input type="text" name="phone"  class="form-control" id="agent_phone" placeholder="<?php _e('Your Phone', 'wpestate'); ?>" >
        <textarea id="agent_comment" name="comment" class="form-control" cols="45" rows="8" aria-required="true" placeholder="<?php _e('Your Message', 'wpestate'); ?>" ></textarea>    

        <input type="submit" class="wpresidence_button agent_submit_class"  id="agent_submit" value="<?php _e('Send Message', 'wpestate');?>">

here is my page: http://landbankrealestate.com/en/properties/lote-en-condominio-las-vueltas/ it will be great if you can give me some tips

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.