473,657 Members | 2,523 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Form Confirmation Problem

Hi,

I'm having this problem and I can't seem to solve it.

I've created a confirmation page. The page displays the form field
data and has
2 links - OK (to continue) and Cancel (go back to form).

The OK button will continue to validate the form values, cancel to
close window.
The problem starts here. I get script error and the error message
doesn't tell me
what's the problem.

Also how do I include the form action code?

Can someone help me, pls? Your help/guidance is much appreciated!

Rgds,
Kelvin
<SCRIPT LANGUAGE="JavaS cript">
<!--
function display()
{
var x;
DispWin = window.open('', 'ConfirmPage',
'toolbar=no,sta tus=no,width=30 0,height=200')
message = "<ul><li><b>des tination: </b>" +
document.form1. destination.val ue;
message += "<li><b>Wei ght: </b>" + document.form1. Weight.value;
message += "<li><b>departu re: </b>" + document.form1. departure.value
+ "<br>";

message += "\nChoose OK to submit these values, or\n"
message += "Cancel to return to the form. <br><br>";
message += "<a href='javascrip t:onclick='open er.document.for m1.checkForm1() ;self.close();' '>OK</a>
"; //ERROR ON THIS LINE.

DispWin.documen t.write(message );
}
function checkForm1()
{
if(document.for m1.destination. value == "")
{
alert("Destinat ion must not contain numbers at all.");
document.form1. destination.foc us();
return false;
}

if(document.for m1.departure.va lue == "")
{
alert("Origin must not contain numbers at all.");
document.form1. departure.focus ();
return false;
}

if(document.for m1.station.valu e == "")
{
alert("Please provide the station.");
document.form1. station.focus() ;
return false;
}
}

// End -->
</script>

<form method="post" name="form1">

<input name="destinati on" type="text" value="US">

<input name="Weight" type="text" value="456">

<input name="departure " type="text" value="UK">

<input name="submit" type="submit" value="Quote" onClick="displa y();">

</form>
Jul 23 '05 #1
2 1729
In article <ca************ **************@ posting.google. com>,
ke*******@yahoo .com enlightened us with...
Hi,

I'm having this problem and I can't seem to solve it.

You have incorrectly nested quotes, among other problems.

<SCRIPT LANGUAGE="JavaS cript">
<script type="text/javascript">
The language attribute is deprecated.

<!--
I don't think there is a single human being using a browser that doesn't
understand script any more. You can drop the comments.
There is a difference between disabled script and not understanding script.
Browsers used to not understand script. I think the last browser that didn't
get it was netscape 3 or something else very, very old. ;)
function display()
{
var x;
DispWin = window.open('', 'ConfirmPage',
'toolbar=no,sta tus=no,width=30 0,height=200')
You understand the risks with using window.open, right?
message = "<ul><li><b>des tination: </b>" +
document.form1. destination.val ue;
Invalid HTML will be written to the new page if you don't stick the right
tags in there. You seem to have forgotten the html, head, and body tags.
message += "<li><b>Wei ght: </b>" + document.form1. Weight.value;
message += "<li><b>departu re: </b>" + document.form1. departure.value
+ "<br>";

message += "\nChoose OK to submit these values, or\n"
message += "Cancel to return to the form. <br><br>";
message += "<a href='javascrip t:onclick='open er.document.for m1.checkForm1() ;self.close();' '>OK</a>
"; //ERROR ON THIS LINE.

You didn't nest the quotes right. Backslash-escape the singe quotes embedded
in the single quotes.
And you understand the risks with using javascript as an anchor target,
right?

message += "<a href='javascrip t:onclick=\'ope ner.document.fo rm1.checkForm1
();self.close() ;\''>OK</a>";
{
if(document.for m1.destination. value == "")
{
alert("Destinat ion must not contain numbers at all.");
document.form1. destination.foc us();
return false;
}


Returning false cancels form submission IF you put the validation in onSubmit
with a return and the submission is done from a submit button. You aren't
doing that, plus you close the window regardless of the return value.
Drop the self.close all by itself. It will close the window even if the form
didn't submit. Put it in the validation/submit routine and call only if
everything passed validation.
Don't bother returning any value if you're keeping this format.

Do this instead:
message += "<a href='javascrip t:onclick=\'ope ner.document.fo rm1.checkForm1( );
\''>OK</a>";

checkForm1: (pseudocode)
do all the checks
if (any are bad)
return
else
set action
submit form in opener
close self
end if

--
--
~kaeli~
A lot of money is tainted - It taint yours and it taint mine.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #2
On Mon, 27 Sep 2004 09:12:01 -0500, kaeli <ti******@NOSPA M.comcast.net>
wrote:
I think the last browser that didn't get it was netscape 3 or something
else very, very old. ;)
According to the Netscape reference, Netscape 2.0 implemented JavaScript
1.0. That means that you'd have to go back to the first version of
Netscape to find a browser that couldn't execute a script. I think "very,
very old" is an understatement!

[snip]
In article <ca************ **************@ posting.google. com>,
ke*******@yahoo .com enlightened us with...

message = "<ul><li><b>des tination: </b>" +
document.form1. destination.val ue;


Invalid HTML will be written to the new page if you don't stick the
right tags in there. You seem to have forgotten the html, head, and body
tags.


You also forgot to mention that when a script placed directly inside a
HTML document contains the sequence, "</", it should be escaped to ensure
no browser mistakes that for the end of the SCRIPT element. The line above
should read:

message = "<ul><li><b>des tination: <\/b>"
+ document.form1. destination.val ue;

[snip]

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2742
by: Calvin | last post by:
Hi, Envronment: IIS 5 on W2k sp3 Problem: I'm using a Form and when Submitted, will display a confirmation page. The confirmation page is simply a Form with an OK button. I want the browser to display either the first form OR to another page and I couldn't do either.
9
2169
by: Jack | last post by:
Hi, I got a asp form page where the POST ACTION = confirmation.asp page is used to save the values collected from text boxes from the form in a database. For example txtTotalOutlay field is being used in confirmation.asp page to update a database field. However, there is a field in the form which is calculated field e.g. NetOutlay = .90 * txtTotalOutlay. This NetOutlay is thus not a text field. However, in the confirmation field I...
4
1473
by: Sridhar | last post by:
Hi, I have a vb6 form which has a label on it. When they click on that label it will display the new web form and ask them to fill details. Once they fill details it will give confirmation number. Can i pass this confirmation number back to windows form and display it using Message box? please let me know Thanks,
16
3142
by: whyyyy | last post by:
The script below works fine if the form is filled out and submitted. But a (blank) e-mail is sent whenever the page loads, even when the form is not submitted. I would like to receive the e-mail only when the form is submitted <%@LANGUAGE="VBSCRIPT"%> <% Set MyMail=CreateObject("CDO.Message")
1
1485
by: geckobtz | last post by:
Hi Guys, I am trying to build a page in ASP/MSsql with the aid of dreamweaver, the page contains total of 6 Questions, each question has 3 choices, of which one of the choice contains the right answer with a hidden value = to 1 and the wrong choice hidden value = to 0. What i am trying to achieve is to collect the values and insert it to a database and at the same time display the results on the confirmation page. Collecting data’s and...
5
2185
stepterr
by: stepterr | last post by:
Hi Everyone, I'm new to PHP and have been working on an existing from that had been in Coldfusion but needed to be converted to PHP. I have most of it working except I ran into a problem when trying to email the form, the values are showing up blank. I believe it has to do with the flow and how the last step before the email process doesn't actually have the values in input fields, rather just displays the information with in html tags using...
12
3824
by: colt28 | last post by:
Ok so I found an ajax contact form script but i can't get the b****** to work. I made a bunch of alterations to it and it didn't work so i replaced everything with the original and it still didn't work...dunno why, but anyhow. The form appears after a delay on the page in a hidden DIV. The original form just had name, email and message, but i have to add a few questions to it so i did and i also added some code from another script i found to...
7
3331
by: bleachie | last post by:
Hey, I just need some help, my form seems to not send me all of the 'guestNames' and 'guestEmails' forms. i use this function to add more guestnames and guestemail fields based on the number of guests added. form.php function createGuestNameAndEmailElements() {
5
3203
by: jmartmem | last post by:
Greetings, I have built an Update Record Form in an ASP page. This form contains a number of fields, such as text boxes and menus, to name a few. Upon clicking the 'submit' button, I want the form values to pass to a confirmation page that shows the values entered and selected, with a CDONTS auto email generated at the same time. My problem is that I'm having trouble passing the values from the form to both the confirmation page and the...
0
8403
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8316
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8610
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7345
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6174
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4327
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2735
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1967
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1730
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.