so i've got a form that submits data into another frame - this all works fine. but what i want to do is clear one of the fields on the form after it's been submitted.
i tried something like this:
<form method=post target='bottom'>
<input type=text size=100 name='text'>
<input type=submit value="send" onClick="javascript:document.forms[0].text.value = '';">
</form>
but the problem here is that it clears the field -before- it's been submitted, not after. so is there any way around that?
Use onUp not onClick
This is now the general JavaScript thread, unless someone wants to make a new start for a better, more general thread.
That would be "onmouseup", and not "onup". Also, it probably wouldn't work.
Try this instead:
onClick="document.forms[0].submit(); document.forms[0].text.value = '';"
Even better, use IDs for the elements you want to access, and document.getElementById
, since documents.forms[]
is quite non-standard.
>>4
thanks!
somewhat related question - is it possible for javascript to act on the contents of another frame?
Mmmmaybe. I know I've managed to get Javascript in an iframe acting on content in its parent. You'll need to explore the various wonderful arrays and elements in document. I recommend the Firefox DOM inspector for this.
bah. parent.framename.whatever (or top.framename.whatever), works fine in IE, but Firefox doesn't like it. bastard.
that's because firefox uses standards. ie's way of doing it is nonstandard. try digging into parent.frames[], or actually break open the DOM inspector and look at exactly what javscript objects Firefox exposes, instead of just guessing. It's all there, and you don't even have to rtfm; just click around in the DOM inspector with it set to display javascript objects. what could be easier?