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

why doesn't this reset my form? 1

Status
Not open for further replies.

ixnay5

MIS
Jan 10, 2002
68
US
in my form page I have:

Code:
<script type="text/javascript" src="frm_btx4k_slave.js"></script>

<form name="mainform">

...form elements, etc....

<input type="button" name="reset" value="reset" onclick="myreset();">

in my javascript page (frm_btx4k_slave.js) i have:

Code:
function myreset(){

	document.mainform.reset();
	
}


i keep getting an "object doesn't support this property or method" error when i hit the reset button.?
 
I think you're looking for refresh(), but I never use that. Rather, I just write:

Code:
document.location = document.location.href;

'not sure about browser compatibility with that.

Anyone?

--Dave
 
might work with netscape, but it doesn't in IE, and that's what i'm developing for.

the reference books i have say reset() is a method of the form object. i can't see where i've implemented it incorrectly, and i'm still getting the error.

[bomb]
 
this line:
Code:
document.mainform.reset();
is attemping to access your button named reset. Name you button "resetButton" and it should work fine.

-kaht

banghead.gif
 
ixnay5 said:
might work with netscape, but it doesn't in IE, and that's what i'm developing for.

I program for IE also and I use document.location all the time without difficulty.

--Dave
 
lookingforinfo:

i was referring to your suggestion that i was looking for refresh(), which doesn't work in ie.

you're right, document.location.href works great.

thx
 
Umm, if your code is only resetting the form, why not just use a reset button?
Code:
<input type="[b]reset[/b]" value="reset">

Adam
while(ignorance){perpetuate(violence,fear,hatred);life=life-1};
 

>> I keep getting an "object doesn't support this property or method" error when i hit the reset button

this is because you ahve named your reset button "reset". If you change the name to "myReset" all will work. The form doesn't know if you are referring to the "reset" method, or to the "reset" button.

Hope this helps,
Dan
 
>> this is because you ahve named your reset button "reset". If you change the name to "myReset" all will work. The form doesn't know if you are referring to the "reset" method, or to the "reset" button.

JINX!

:)

-kaht

banghead.gif
 
adam0101:

long story involving another thread. prob. the less said about it the better, but here goes: i was trying to write a simple function that i could put in <body onload=""> so that if i couldn't get the dynamic divs i'm using to redisplay when the user hits the back button, at least i could make the form clear out completely on the back button. to me, that's preferable to a partially displayed, partially filled in form.

thanks!

turns out, kaht spotted the problem!
 
khat. that was the problem. thanks for spotting it.
 
>> JINX!

Hi kaht [wavey2]

Sorry - I didn't see your answer at all... That'll teach me to blindly stab at the keyboard without reading the full thread ;o)

Interesting - it's the first time I've seen this problem with a reset button though - it's normally the submit button that does it!

Dan
 
Ok, I see. Another option would be to disable the cache on the form page.

Adam
while(ignorance){perpetuate(violence,fear,hatred);life=life-1};
 
>>Interesting - it's the first time I've seen this problem with a reset button though - it's normally the submit button that does it!

Agreed.

-kaht

banghead.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top