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

How to clear the value of a text field

Status
Not open for further replies.

kloner

Programmer
May 15, 2000
79
AU
Hi all,

Benn stumped on this problem all day ... I have the following :

<input type=text name=name1 value=bob>

NOW 'bob' is read from a database ok.

problem is ... when i remove the word 'bob' form the textfield and hit submit to pass '' (nothing) it still passes 'bob'

I have been playing with JS and when I submit the following is called ...



if (document.form1.name1.value = &quot;&quot;)
{
document.form1.name1.value = &quot;&quot;
}

i don't know what is going on, any help much appreciated.

matt
 
first, try this:
<input type=text name=name1 value=&quot;bob&quot;>

second, if you are triggering the function onsubmit,
the submit happens first.

you need to use an input type button instead of submit and trigger both the function
and the submit onclick

<input type=button name=name1 onclick=&quot;clear_and_submit()&quot; >

function clear_and_submit() {
document.form1.name1.value=&quot;&quot;;
document.form1.submit()
}
 
I am having trouble clearing a dropdown box ...

IE. I have -
1. Select one
2. option 1
3. option 2
4. option 3
5. option 4

The name of the dropdown box is 'relationship'

I have used : document.form1.relationship.value = &quot;&quot;; which works fine in IE, but doesn't in Netscape. What should I be putting in for it to work in Netscape? [sig]<p>Matthew Wall<br><a href=mailto: > </a><br><a href= > </a><br> [/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top