473,396 Members | 2,020 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

loading ASP from javascript, missing text in input-boxes

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
2 2841
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Andrew V. Romero | last post by:
I have a script that I am working on for an intranet tool and in this script I have a form, which when submitted the onSubmit command calls calculate(). In this calculate function, I have it do...
3
by: Jacques Chaurette | last post by:
Hello all , thanks in advance for any help. While looking for a solution to how to replace the grey box while an applet loads, a search of Google got me an article by Glenn s. Peffers that claims to...
4
by: Ike | last post by:
Oh I must be missing somethign so simple and stupid. I need to do a submit() via an href, which I do (succesfully) in JavaScript in many other pages with <a...
2
by: christopher.secord | last post by:
I would like have a little "loading..." tab not unlike the one that gmail uses and I would like to display that tab while an ajax call is made. The javascript to display the tab works. The...
17
by: CES | last post by:
All, I was wondering if their is a way of loading an external script fill from within a script?? <script language="javascript" type="text/javascript"> function test(var){ <script...
8
by: chrisdude911 | last post by:
how do i add video into a javascript web page with my own custom buttons?
4
by: Adam Smith | last post by:
Hello, How can I call or trigger an external javascript twice in a form? I have <script language="JavaScript" src="country_state.js" name="Country_State"> <script type="text/javascript"...
1
by: kokababu | last post by:
I am trying to load dojo module from different domain; such as dojo.parser, dijit.form.TextBox etc. <html> <head> <script type="text/javascript"> djConfig = { isDebug: true,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.