post and javascript and whatnot (8)

1 Name: #!usr/bin/anon 2005-10-05 15:06 ID:kvicYtST

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?

2 Name: #!usr/bin/anon 2005-10-05 15:10 ID:Heaven

Use onUp not onClick

3 Name: #!usr/bin/anon 2005-10-05 15:54 ID:UWEyhRLS

This is now the general JavaScript thread, unless someone wants to make a new start for a better, more general thread.

4 Name: !WAHa.06x36 2005-10-05 17:13 ID:RTD9iJb3

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.

5 Name: #!usr/bin/anon 2005-10-06 20:02 ID:A0Xi0cnj

>>4
thanks!
somewhat related question - is it possible for javascript to act on the contents of another frame?

6 Name: !WAHa.06x36 2005-10-06 20:15 ID:RTD9iJb3

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.

7 Name: #!usr/bin/anon 2005-10-08 11:06 ID:Dp3cUjmq

bah. parent.framename.whatever (or top.framename.whatever), works fine in IE, but Firefox doesn't like it. bastard.

8 Name: #!usr/bin/anon 2005-10-12 12:27 ID:yHGfmqsH

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?

This thread has been closed. You cannot post in this thread any longer.