473,396 Members | 1,693 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.

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="JavaScript">
<!--
function display()
{
var x;
DispWin = window.open('','ConfirmPage',
'toolbar=no,status=no,width=300,height=200')
message = "<ul><li><b>destination: </b>" +
document.form1.destination.value;
message += "<li><b>Weight: </b>" + document.form1.Weight.value;
message += "<li><b>departure: </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='javascript:onclick='opener.document.form1.ch eckForm1();self.close();''>OK</a>
"; //ERROR ON THIS LINE.

DispWin.document.write(message);
}
function checkForm1()
{
if(document.form1.destination.value == "")
{
alert("Destination must not contain numbers at all.");
document.form1.destination.focus();
return false;
}

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

if(document.form1.station.value == "")
{
alert("Please provide the station.");
document.form1.station.focus();
return false;
}
}

// End -->
</script>

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

<input name="destination" 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="display();">

</form>
Jul 23 '05 #1
2 1714
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="JavaScript">
<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,status=no,width=300,height=200')
You understand the risks with using window.open, right?
message = "<ul><li><b>destination: </b>" +
document.form1.destination.value;
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>Weight: </b>" + document.form1.Weight.value;
message += "<li><b>departure: </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='javascript:onclick='opener.document.form1.ch eckForm1();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='javascript:onclick=\'opener.document.form1.c heckForm1
();self.close();\''>OK</a>";
{
if(document.form1.destination.value == "")
{
alert("Destination must not contain numbers at all.");
document.form1.destination.focus();
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='javascript:onclick=\'opener.document.form1.c heckForm1();
\''>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******@NOSPAM.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>destination: </b>" +
document.form1.destination.value;


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>destination: <\/b>"
+ document.form1.destination.value;

[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
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...
9
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...
4
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...
16
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...
1
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...
5
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...
12
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...
7
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...
5
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...
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
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,...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
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,...

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.