PDA

View Full Version : Auto Submit Loop Issue



theflyingminstrel
02-28-2009, 05:04 PM
Hi all what is the best way to get this to stop looping, and only submit once?

Thanks

<script>document.frmSelect.submit();</script>

Nile
03-01-2009, 01:20 AM
What do you mean? Can your provide all your code and a link to your page please?
You should also use:



<script type="text/javascript">

theflyingminstrel
03-01-2009, 04:23 AM
Hey Nile I'm not at my house now and I'm having trouble remoting in but essentially the javascript is called by asp code and I really only need to call it once but it just keeps on looping.

Thanks

Nile
03-01-2009, 04:27 AM
Ok.. Hmm, put this at the top of your page:


<script type="text/javascript">
var once = true;
</script>

And replace your above code with:


<script type="text/javascript">
if(once){
document.frmSelect.submit();
} else {
return ;
}
</script>

theflyingminstrel
03-01-2009, 06:46 AM
Hi, thanks again. I made a test document and I don't think it's working. Maybe I'm implementing it wrong:

test.asp



<html>

<head>
<script type="text/javascript">
var once = true;
</script>

</head>

<body>

<form name="frmSelect" action="test.asp" method="post">
<input type="text" name="test" value="test">
<input type="submit" name="submit" value="submit">

<%
If request.form("submit") <> "" then
response.write "submitted"
End If
%>

</form>

<script type="text/javascript">
if(once){
document.frmSelect.submit();
} else {
return ;
}
</script>

</body>

</html>

Nile
03-01-2009, 03:37 PM
Why do you want your forum to automatically submit anyways?

Master_script_maker
03-01-2009, 11:25 PM
Ok.. Hmm, put this at the top of your page:


<script type="text/javascript">
var once = true;
</script>

And replace your above code with:


<script type="text/javascript">
if(once){
document.frmSelect.submit();
} else {
return ;
}
</script>

this will still loop. you have to set the variable once to false once it is run:

<script type="text/javascript">
if(once){
document.frmSelect.submit();
once=false;
} else {
return ;
}
</script>
i am not familiar with asp but try:
<%
If request.form("submit") <> "" then
response.write "submitted<script type='text/javascript'>once=false;</script>"
End If
%>