Question
Hi,
This may be more of a programming question than of Twiki. I have this code to generate a page for user input.
<form name="testform" action="%SCRIPTURLPATH%/view%SCRIPTSUFFIX%/%WEB%/%TOPIC%" method="post">
Your input: <input type="text" name="test" />
<input type="submit" class="twikiSubmit" value="Submit" />
</form>
You entered %URLPARAM{"test"}%
... as given below:
You entered **
After submitting the form, the URLPARAM value is not cleared automatically and hence if the user refreshes the screen, the input is posted again. The is creating problems for me (the entry goes into the database again, in the application I am trying to create).
Is there an easy way (for a non-programmer) to clear the value once it is posted ?
Environment
--
ChengappaCB - 20 Dec 2008
Answer
If you answer a question - or have a question you asked answered by someone - please remember to edit the page and set the status to answered. The status is in a drop-down list below the edit box.
Your form action could point to an intermediary page that does the desired action, then redirects back to the originating page.
--
PeterThoeny - 21 Dec 2008
You could also make a hidden input field (<input "name="SubmittedOrNot" type="hidden" value="no" ..) in your form, and set it to "submitted" when the user submits the form.
And in the
OnClick event of the submit button, you could send it to a small javascript function that checks to see the value of that hidden field; and if it's "submitted" then it does not process the form. If it's "no" then it will continue submitting the form (and set the value of that hidden input field to "submitted").
This would require only a little bit of scripting -- you could probably find some samples online!
--
KathyDeLaCruz - 22 Dec 2008
Good suggestion; closing this question...
--
PeterThoeny - 29 Dec 2008