By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,230 Members | 2,436 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,230 IT Pros & Developers. It's quick & easy.

loading ASP from javascript, missing text in input-boxes

P: n/a
I have made an asp-page. When pressing Submit, the form loads a
javascript, for evaluating the input values. The asp-page is being
reloaded from the javascript, to save the input-values.
The evaluation-script is running fine, but when the ASP-script has to
save the value in txtFolder, the record is being added, but the saved
value from input 'Folder' is empty.

The tFolder-value is used when the ASP-page is loading values to edit
existing records.

<%
' ASP script
rs.fields("Folder").value = Trim(Request.Form("txtFolder"))
%>

<script type="text/javascript">
function EvaluateValues(ASPFile){
if (TestValues() == true) {
document.location.href=ASPFile;
}
}
</script>

<form name="MyForm" method="Post"
action="javascript:EvaluateValues('Paper.asp?mode= Add')">
<input type="text" value="<%=tFolder%>" maxlength="1" name="txtFolder"
size="1">
<input type="submit" value="Save" name="B1"></form>

But where does the link break.

I hope you can see my problem. No values are being saved.

Thanks

Jorgen
Jul 19 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Change your FORM tag to be <FORM METHOD=post ACTION=paper.asp> and
change your submit button to be <INPUT TYPE=BUTTON value='SAVE'
onclick='EvaluateValues()'> instead. You will also need to change the
Javascript as follows:

<script type="text/javascript">
function EvaluateValues(){
if (TestValues() == true) {
document.forms[0].submit();
}
}
</script>

Because your Javascript is doing a navigate using
document.location.href, the form data is never posted when the page
navigates. By using the document.forms[0].submit() it will post the
form data, and the <FORM ..> tag will tell it where to post the data
to.

jo*********@ofir.dk (J?rgen Jensen) wrote in message news:<e3**************************@posting.google. com>...
I have made an asp-page. When pressing Submit, the form loads a
javascript, for evaluating the input values. The asp-page is being
reloaded from the javascript, to save the input-values.
The evaluation-script is running fine, but when the ASP-script has to
save the value in txtFolder, the record is being added, but the saved
value from input 'Folder' is empty.

The tFolder-value is used when the ASP-page is loading values to edit
existing records.

<%
' ASP script
rs.fields("Folder").value = Trim(Request.Form("txtFolder"))
%>

<script type="text/javascript">
function EvaluateValues(ASPFile){
if (TestValues() == true) {
document.location.href=ASPFile;
}
}
</script>

<form name="MyForm" method="Post"
action="javascript:EvaluateValues('Paper.asp?mode= Add')">
<input type="text" value="<%=tFolder%>" maxlength="1" name="txtFolder"
size="1">
<input type="submit" value="Save" name="B1"></form>

But where does the link break.

I hope you can see my problem. No values are being saved.

Thanks

Jorgen

Jul 19 '05 #2

P: n/a
On 20 Mar 2004 21:38:51 -0800, Nathan <na******@yahoo.com> wrote:
Change your FORM tag to be <FORM METHOD=post ACTION=paper.asp> and
change your submit button to be <INPUT TYPE=BUTTON value='SAVE'
onclick='EvaluateValues()'> instead. You will also need to change the
Javascript as follows:

<script type="text/javascript">
function EvaluateValues(){
if (TestValues() == true) {
document.forms[0].submit();
}
}
</script>

Because your Javascript is doing a navigate using
document.location.href, the form data is never posted when the page
navigates. By using the document.forms[0].submit() it will post the
form data, and the <FORM ..> tag will tell it where to post the data
to.


[snipped top-post]

However, the form is now totally dependent on JavaScript for no good
reason. A better solution would be:

<form method="post" action="Paper.asp?mode=Add"
onsubmit="return TestValues()">
<input type="text" value="<%=tFolder%>" maxlength="1"
name="txtFolder" size="1">
<input type="submit" value="Save" name="B1">
</form>

Mike
Please don't top-post

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.