I am working on a project where I want to take any opt in form and count how many times it was submitted. After extensive research (I know that Javascript is client side and PHP is server side) I came up with a solution. What I did was to add a tag to the beginning of the form with an "onsubmit" tag calling a Javascript which in turn submits a hidden form which posts to my PHP program that updates the databases.
Javascript/Php Issue
3
I am working on a project where I want to take any opt in form and count how many times it was submitted. After extensive research (I know that Javascript is client side and PHP is server side) I came up with a solution.
What I did was to add a tag to the beginning of the form with an "onsubmit" tag calling a Javascript which in turn submits a hidden form which posts to my PHP program that updates the databases.
This works great except... If I leave the opt in page and come back, it won't work anymore. I have tried everything that I can think of, I changed the hidden form action to post the vars directly without using the hidden inputs, I have tried changing it to open the file in a hidden div or even the main window (The php program has no output) Does anyone have any ideas why it will stop working when the window looses focus? the code is added below:
<form onsubmit="return OnButton1();" action="http://yahoo.com">
<input type="text" value="Your Name Here" />
<input type="text" value="Your Email Here" />
<input type="submit" value=" " />
</form>
</div>
<form name = "Formzilla" action = "http://www.mysite.com/lpage/maillist.php" method ="post">
<input type="hidden" name = "item" value = "1">
<input type = "hidden" name = "page" value = "3">
</form>
<script language="javascript">
function OnButton1()
{
document.Formzilla.submit();
return true;
}
</script>
What I did was to add a tag to the beginning of the form with an "onsubmit" tag calling a Javascript which in turn submits a hidden form which posts to my PHP program that updates the databases.
This works great except... If I leave the opt in page and come back, it won't work anymore. I have tried everything that I can think of, I changed the hidden form action to post the vars directly without using the hidden inputs, I have tried changing it to open the file in a hidden div or even the main window (The php program has no output) Does anyone have any ideas why it will stop working when the window looses focus? the code is added below:
<form onsubmit="return OnButton1();" action="http://yahoo.com">
<input type="text" value="Your Name Here" />
<input type="text" value="Your Email Here" />
<input type="submit" value=" " />
</form>
</div>
<form name = "Formzilla" action = "http://www.mysite.com/lpage/maillist.php" method ="post">
<input type="hidden" name = "item" value = "1">
<input type = "hidden" name = "page" value = "3">
</form>
<script language="javascript">
function OnButton1()
{
document.Formzilla.submit();
return true;
}
</script>
- BenB969 Banned
- [1] reply
- danmart
Next Topics on Trending Feed
-
3