bigtoe
Posts: 115
|
| Posted: 08/29/2004, 4:37 AM |
|
On this form page there are 24 text fields.
Each field is allowed a maximum of 80 characters.
Each field has some default text that is displayed
when the page loads.
The user can accept the default text in each
field or edit it.
But under some conditions the default text does
not apply and the user has to clear the respective
field by backspacing thru the field.
And this is time consuming because there
are so many text fields.
I would like to put a "Clear" button next to each
of these 24 text fields.
When the user clicks on the "Clear" button, only
the respective field is cleared of any text
(default or otherwise).
So I have 2 questions:
1. What would be the PHP code for clearing a text field?
2. Will this code cause a page reload?
I want to avoid a page reload. I don't want anything
else on the page to be impacted.
|
 |
 |
bigtoe
Posts: 115
|
| Posted: 08/29/2004, 4:45 AM |
|
Sorry about the double post.
My network connection dropped.
|
 |
 |
Karsten
|
| Posted: 08/29/2004, 3:12 PM |
|
Use Javascript in this case because PHP is a SERVERSIDE language this is, the page has to be "reload" better say reprocessed to do a practicular change to something.
with javascript you can solve the problem much smarter and less server-resource consuming.
and i would sugesst you dont use a button to clear the field just clear it if it is clicked on, to do this:
1. add a javascriptfunction to clear a textbox to your page
you can find an example here http://www.java-cripts.net/javascripts/Field-Clear-Script.phtml
2.Select a Textbox in Designview
3.in the right propertythingy klick on the Format Tab
4. scroll down, you will find a closed tree "Events"
5. open this tree
6. what you see here are so called "clientside events" they occour on clientside only but in your case this is ok because you just easy want to clear a textbox value(the text in this case)
7.choose the right event, in this case onClick in the in the clear space behind the onClick event put the call to the javascriptfunction you added in step 1.
if you use the sample i told you the call would look :
doClear(this)
8. repeat steps 2-8 for all textboxes you want to clear after user clicked on
if you want to use a button instead of my sugesstion just use the onClick event of the Button(s) instead of the Onclick events of the textbox
i hope this works with CCS.
Karsten from Germany
(a bit desperate again, because yesterday a directory forms HTML was messed up so unusable i had to redo a daywork)
|
|
|
 |
|