Parent / Children forms and data

A

Al Jones

I have an application - an insurance form - which requests personal data on
form one. If the user checks auto or homeowner (or both) on the first form
I need to collect data from each of these (popup?) forms (Auto and HomeOwner
respectively) and then write this collected data to an email message.

Passing selected data to the child forms via the url is possible, but I'm
certain I'd run into a length problem. Since I still have the parent open
then windows.opener.<var>.value is reasonable(??).

Presuming that the user checks both homeowner and auto, after one form is
closed (and we return to the parent) how do I pass this data back to the
parent form?

Session objects (on client side?) appear to be a possible means of passing
data both ways, but I'm not certain from what I've read. Since references
to session variables seems slim - I presume there are better ways. What is
the best <??>, most commonly used way??

When all is said and done - I pass the form to VB ASP script to write the
message (or at least I have done so with several other single page forms).
How do I pass this colloelction of data to something to generate an email
message?

History: I'm an old COBOL / APL / C programmer trying to catch up with the
times, I'm not asking anyone to write code for me - but would surely
appreciate anyone making suggestions and/or pointing me toward appropriate
references.

Thanks //al
 
M

Michael Winter

I have an application - an insurance form - which requests personal data
on form one. If the user checks auto or homeowner (or both) on the
first form I need to collect data from each of these (popup?) forms
(Auto and HomeOwner respectively) and then write this collected data to
an email message.

It would be a grave error to make a commerical website dependant upon
pop-ups. Even requested pop-ups are likely to be blocked on some systems,
and the user probably won't realise that they are missing part of the
process.

If the user checks one (or both) of those boxes, the server should
generate an intermediary page that contains the extra fields necessary.
Once they have been filled, the total data set can be passed for final
processing.
Passing selected data to the child forms via the url is possible, but
I'm certain I'd run into a length problem. Since I still have the parent
open then windows.opener.<var>.value is reasonable(??).

window.opener.forms['formName'].elements['elementName'].value

But you shouldn't need to do this, as I described above.
Presuming that the user checks both homeowner and auto, after one form
is closed (and we return to the parent) how do I pass this data back to
the parent form?

One possible way is to get the user to click on a button which writes the
data back, the closes the window. However, what if the user just closes
the window (users do these things)? The data will be lost. An alternative
would be attach change listeners to all the fields that would write the
data back.

The server-side approach is looking more and more appealing...
Session objects (on client side?) appear to be a possible means of
passing data both ways, but I'm not certain from what I've read.

It certainly shouldn't be relied upon. The user can disable cookies.
Cookie data is also limited in size.
Since references to session variables seems slim - I presume there are
better ways. What is the best <??>, most commonly used way??

I would store the data in a database temporarily, giving each user a
unique session id (either stored in a cookie, or in the URL). The
intermediary step I described can add to this data, if necessary.
Alternatively, you could write the data back to intermediary page as
hidden form inputs.

There may well be better approaches, though.
When all is said and done - I pass the form to VB ASP script to write
the message (or at least I have done so with several other single page
forms). How do I pass this colloelction of data to something to generate
an email message?

Most form mail scripts take POST request data and write out the data as
form control name/value pairs. You could either modify such a script to
pull data from the database (if you choose that option), or submit it all
straight to the mail script.

I would say that this question is more appropriate in an ASP group. They
are:

microsoft.public.dotnet.framework.aspnet
microsoft.public.dotnet.framework.aspnet.webservices
microsoft.public.inetserver.asp.components
microsoft.public.inetserver.asp.db
microsoft.public.inetserver.asp.general

Good luck,
Mike
 
J

Joakim Braun

Al Jones said:
I have an application - an insurance form - which requests personal data on
form one. If the user checks auto or homeowner (or both) on the first form
I need to collect data from each of these (popup?) forms (Auto and HomeOwner
respectively) and then write this collected data to an email message.

Passing selected data to the child forms via the url is possible, but I'm
certain I'd run into a length problem. Since I still have the parent open
then windows.opener.<var>.value is reasonable(??).

<snip>

Depending on the browser versions you need to support - how about <span>ing
whatever form elements are required for the homeowner/auto data, and showing
the <span> only if the corresponding checkbox is checked? (by adjusting the
<span>'s style.display/style.visibility)

Joakim Braun
 
A

Al Jones

Joakim Braun said:
<snip>

Depending on the browser versions you need to support - how about
whatever form elements are required for the homeowner/auto data, and showing
the <span> only if the corresponding checkbox is checked? (by adjusting the
<span>'s style.display/style.visibility)

Joakim Braun
Would you elucidate please....
 
M

Michael Winter

[snip]

I'd recommend either grouping the elements in a DIV, or hiding the
elements directly. A SPAN just adds bulk.

It also might be a good idea to disable the elements as well as hide them.
If the browser doesn't support the style object, at least it will stop a
user entering values by mistake.
Would you elucidate please....

One of the CSS properties introduced in the second version of the
specification was visibility. It, along with display (introduced in
version one), allows elements to be hidden. With recent browsers, it's
possible to alter the visible state dynamically using the style object.

The difference between an element hidden by visibility and an element
hidden by display, is that the former affects layout; the browser
allocates space but doesn't render the element or its content. The latter
collapses the space used; it's as though the element wasn't there at all.

For example,

<body onload="initialiseForm()">

<!-- other page elements -->

<form ... id="myForm">
<label for="auto">Automobile:
<input id="auto" name="auto" type="checkbox"
onclick="toggleAuto(this.form, this.checked)"></label>
<!-- other form elements -->
<input ... id="myInput">
</form>

<!-- other page elements -->

</body>


function displayElement(o, d) {
if(o.style) {o = o.style;}
o.display = d ? '' : 'none';
}

function initialiseForm() {
var f = document.forms['myForm'];

displayElement(f.elements['myInput'], false);
/* Hide other dependant elements. */
}

function toggleAuto(f, d) {
displayElement(f.elements['myInput'], d);
/* Toggle other elements dependant upon 'auto'. */
}

If you search the archives, you'll find more complete examples.

I admit that I forgot about this when I wrote my first reply. I still
think a server-side solution would be more reliable.

Hope that helps,
Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top