Jump to content

Need Help with PHP Forms :/


joel2k8

Recommended Posts

Hello People,

 

Im having trouble with my php form, It works and everything

 

The thing is that i want to do, Do you no the Text Box, Its automaticaly got text in the box, But i want it so when a person clicks inside the text box, The text dissapears, Please Help, Thanks

 

Heres my form:

<form method="get" action="searchname.php"/>
<input type="text" size="13" name="name"  value="User Search" class="SearchField" onfocus="if(!this._haschanged){this.value=""};this._haschanged=true;" />
<input type="image" src="images/search.png" name="go" alt="go" class="go" title="go" />
</form>

 

The value makes it so theres already text in the box, But i want it so when a person clicks the box the text dissapears, Thanks

Link to comment
Share on other sites

I'm sorry, I'm having troubles what you are asking. I'm assuming you are speaking English as a second language? Maybe you could try and explain it again, and I will help you if I can.

 

By the way, it's 'know', not 'no'. 'No' is the opposite of 'yes', 'know' means to understand something.

 

 

Link to comment
Share on other sites

Ok Sorry, I'll try and Explain the Hard Way

 

What i want to do is, When a Person goe's on my Website and See's my Text Box (Form)

They would already see writing in the Text Box, Because Thats what I put in My Code (value="User Search")

This is what i want to do,

When a Person Clicks the Text Box the Writing Dissapears, It just takes it away and then you can write in what you want, But what it doe's now is when a Person clicks the Text Box, The writing Doesnt go away, I want it automatically go away when a person Clicks the Text Box,

 

Now do you understand, Sorry About first Post, I was in a Hurry :/

Link to comment
Share on other sites

Ah yes, I get it.

 

I hope you didn't take offense to my first post - I taught English as a second language for a number of years, so I'm used to writing like yours.

 

One hint - capital letters (the bit letters) only go at the start of sentences. It looks strange to see them on every word.

 

Anyways, here is how you can do what you want. Put this code in the head of your document:

 

<script type="text/javascript">
function textAreaListener()
{
   var targetTextArea = document.getElementById("target_text_area")
   targetTextArea.onfocus = function()
   {
		if(this.value == "some_text")
		{
			this.value = ""
		}
   }
}

window.onload = function()
{
	textAreaListener()
}
</script>

 

And you have to make your text area look like this:

 

<textarea id="target_text_area">some_text</textarea>

 

You can change the 'id' of the textarea (in this case 'target_text_area') to anything, but you have to change the id in the javascript in your head as well. You can also change 'some_text' to anything, but you also have to change that in the javascript as well.

 

Good luck!

 

Link to comment
Share on other sites

Ok thanks for that But I want it in My Form that I posted, I've just tried it, In my form and it Wasnt working

 

<form method="get" action="searchname.php"/>
<input type="text" size="13" name="name"  value="User Search" class="SearchField" />
<input type="image" src="images/search.png" name="go" alt="go" class="go" title="go" />
</form>

 

Thats the Form i would want it in :/

 

Thanks Anyway

Link to comment
Share on other sites

Too many capital letters!

 

Anyways, you can use the following pattern and it will work, as long as the ID is the same as in the javascript:

 

<input type="text" id="target_text_area" value="some_text" />

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.