473,783 Members | 2,516 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

document.write and forms

A straight forward problem I think but my knowledge of JavaScript lets
me down.

I am taking in a lot of input using a form. After preparing an email
(FormMail.pl) I then use 'document.write ' to create a new page with
all the users details nicely formatted. This includes checking radio
buttons, checkboxes etc.

Problem is as soon as I use the first 'document.write ', the form and
all its contents are undefined. I have moved some of them to variables
for the time being but this is cumbersome.

Any solutions to what must be a simple issue greatly appreciated.

John
Jul 20 '05 #1
2 3680
You are going to have to sort out what your display is well before you do
your document.write( ). document.write explicitly calls document.open() if
you haven't done it yourself. Use something like this.

var strText = new String();

strText += "some text 1";
strText += "some text 2";
strText += "etc, etc...";

with (document) {
open();
write(strText);
close();
}

Peter.

"John" <j@laycus.con > wrote in message
news:2n******** *************** *********@4ax.c om...
A straight forward problem I think but my knowledge of JavaScript lets
me down.

I am taking in a lot of input using a form. After preparing an email
(FormMail.pl) I then use 'document.write ' to create a new page with
all the users details nicely formatted. This includes checking radio
buttons, checkboxes etc.

Problem is as soon as I use the first 'document.write ', the form and
all its contents are undefined. I have moved some of them to variables
for the time being but this is cumbersome.

Any solutions to what must be a simple issue greatly appreciated.

John

Jul 20 '05 #2
On Tue, 22 Jul 2003 01:45:02 +0100, "ManoDestra "
<ma************ *****@ntlworld. com> wrote:
You are going to have to sort out what your display is well before you do
your document.write( ). document.write explicitly calls document.open() if
you haven't done it yourself. Use something like this.

var strText = new String();

strText += "some text 1";
strText += "some text 2";
strText += "etc, etc...";

with (document) {
open();
write(strText);
close();
}

Peter.


Thanks Peter

Tried this and got -

some text 1some text 2etc, etc...

as expected (I think) on a fresh page. My document.write then followed
on another fresh page. form still undefined though.

I am not clear what this is telling me.

John
Jul 20 '05 #3

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

Similar topics

6
4524
by: 2obvious | last post by:
This is a pipe dream, I realize, but I'm trying to emulate the functionality of the W3C DOM-supported document.getElementsByTagName method under the very nightmarish Netscape 4. Through some sleuthing, I was able to find what serves as a document.getElementById emulator at http://www.xs4all.nl/~ppk/js/dhtmloptions.html#versionb. (Below is the code; this clever algorithm is painstakingly explained at the site above.)
6
1879
by: Mark Anderson | last post by:
I have code to develop result page links (like a search engine) for some results being passed from a database where I've no server-sdide acces - thus JS. The code is below and works fine except the function in the onClick event of the link being written on screen fails indicating 'theForm' as being passed through is 'not defined'. The form is being passed as "document.resultAdd" and can be checked as arriving in my function. So what...
3
6652
by: Gretjns | last post by:
I'm trying to figure out this script doesn't display any text in the child window and why I'm getting the null or not an object error. It's taken directly from the Javascript and DHTML cookbook (not listed in the book errata on o'reilly website). Initially I get an error "window.dialogArguments.yourName" is null or not an object. Then I fill out the field on the form, press the button and the child window does display but there is no...
15
3326
by: lawrence | last post by:
Is this the correct way to test for a method before I use it? createRange() is, I believe, an IE only method. function wrapSelectionInTag(selection, tag) { if (document.selection.createRange) { var range = document.selection.createRange(); if (range.parentElement() == element) range.text = '<' + tag + '>' + range.text + '<\/' + tag + '>'; }
136
9457
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their code was littered with document.all and eval, for example, and I wanted to create a practical list of best practices that they could easily put to use. The above URL is version 1.0 (draft) that resulted. IMO, it is not a replacement for the FAQ,...
3
1642
by: Martin | last post by:
Hi, I have a number of documents stored on my web server and these documents should not be servered to anybody unless the user is both authenticated and authorized. This authentication and authorization comes from a custom database. To stop users simply requesting the documents directly I have written a http handler to intercept requests for *.doc. This works well and all of my requests are intercepted by the handler.
7
2408
by: Andrea | last post by:
Hi there - I'm hoping someone can help me; I've been struggling with this for a few days! :-) I have a webpage that is comprised of many forms containing questions. As the user answers one of the questions, that form is hidden and the next is displayed. Also, as the user answers each question a "count" variable is updated based on their response. I would like the question to show up on the left side and the answer to show up in the...
10
2702
by: Geoff | last post by:
I am using the following statement in a script: If (res == 123) document.write (" Blah Blah"); else document.write (" XYZ"); This of course brings up a new page on my site and prints Blah Blah. However, the colour of the page is white & I want it to match the colour of the html page from which the original request was sent. I have tried playing with
6
3377
by: therig | last post by:
I'm having issues, I've spent many hours searching and I'm a noob at javascript, any help will be greatly appreciated. I keep getting the following error: Error: document.forms.sec11_A has no properties with this script: function checkform(btntype) {
0
9480
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
10147
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10083
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9946
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...
1
7494
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
6737
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5379
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2877
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.