Click to See Complete Forum and Search --> : Automatic form submission
NatuScape
03-01-2003, 08:58 PM
Hi!
I'm trying to convince a form to submit itself automatically so I can save a value in a field and use it later in the page. The code I'm using is:
<form method="post" name="WhosHere">
<input type="hidden" name="CurrentUser" value="<%=UserIs%>"></p>
</form>
<script language=JavaScript>
document.forms.WhosHere.submit();
</script>
However, when I try this, the form keeps on submitting, it sort of goes into a loop. I tried bumping the code up to the form tag, like this:
<form method="post" name="WhosHere" onload="javascript:document.forms.WhosHere.submit();">
But that doesn't do a thing!!!!!
Ideas?? Comments?? Thank you very much!!
Natalia
Timbuck2
03-01-2003, 09:46 PM
That would appear to make no sense.
if you got the user from the server and then the page loads why do you want to send the user back to the server from whence it just came. and if the post - loads the form again and if it were to submit on load then yes it should continuously post until it fails to load.
What exactly are you trying to do?
NatuScape
03-03-2003, 06:58 AM
Hi Tim and Dave!
What I'm trying to do is submit the form but just stay put, because I'm using that value a bit below for a query. When I add a submit button to the form and click it, it works just fine. I was looking to save the users the clicking part, because I'll always want the form to submit.
I can't figure out why it would work with a button and not with the JS command... Any more ideas will be very welcome!!
Thanks!!!!
Natalia
NatuScape
03-03-2003, 07:19 AM
Can I create an action to click the button upon loading automatically or something like that? Is that possible?
Thanksssss!
Me :)
NatuScape
03-03-2003, 07:24 AM
Yes, I can explain.... What I'm trying to do originally is circumvent FP2002's knack for re-editing the code in a query and it's complete inability to accept a variable (be it server or page generated) as criteria for a query. I'd like my query to read:
"SELECT * FROM Users WHERE userHSE = '" & Request.ServerVariables("AUTH_USER") & "'"
But FP just doesn't like that. If I use their built-in query writer, when I type " inside the box, it turns them into "" when the code is parsed hence disabling my coding. It does, however, accept field values in the form:
"SELECT * FROM Users WHERE userHSE = '::CurrentUser::'"
But for that, I need to put the Request.ServerVariables("AUTH_USER") into a field in a form (fieldname: CurrentUser) and then submit the form. Hence my idea to do this automatically....
Any more ideas?????????? :D
Thanks some more!
Me :)
P.S.: Ah! I know this will work if I go in manually and edit the code "by hand" but then it breaks again when I re-open the page with FP!
NatuScape
03-03-2003, 11:45 AM
Hey! There's a thought!! I actually hadn't wired it like that, but I guess I could.... I'll munch on that idea for a bit :)
Thanks!!!!!
Me :)