Click to See Complete Forum and Search --> : 3 part form, Help!!!!


Yanhead
06-09-2003, 12:19 PM
I have a 3 part form (on 3 seperate html pages). I want to be able to send all the data that is input into the form in one go at the end (of page3). How would this be achieved with cookies as I want to avoid server side scripting?

Thanks

Khalid Ali
06-09-2003, 12:50 PM
if these forms of yours are not huge,then you may not need to use coockies as well.
What you can do is pass the fieldnames assosciated with their values to the next page and then reconstruct the form there.

take a look at this lin.It impleents the same idea.

http://68.145.35.86/skills/javascripts/DemoForwardFormDataViaURL.html

Yanhead
06-09-2003, 01:23 PM
Originally posted by Khalid Ali
if these forms of yours are not huge,then you may not need to use coockies as well.
What you can do is pass the fieldnames assosciated with their values to the next page and then reconstruct the form there.

take a look at this lin.It impleents the same idea.

http://68.145.35.86/skills/javascripts/DemoForwardFormDataViaURL.html

Could I then take all the data (including the data that is entered on the second page) onto a third page and submit all the data (from the 3 pages/parts of the form) there?

I do not need to phsyically see the data on the second page, could this be passed into a hidden field on the second page instead? and so on.

Thanks

Charles
06-09-2003, 01:25 PM
If your form handling script is in Perl then use the CGI.pm module. All you need to do is generate hidden fields with the same names as the form fields you are trying to pass through. The module does the rest.

use CGI qw(:standard);
print header, start_html, start_form, hidden(-name=>'test1', -default=>'someDefault'), end_form, end_html;

Khalid Ali
06-09-2003, 01:27 PM
Originally posted by Yanhead
Could I then take all the data (including the data that is entered on the second page) onto a third page and submit all the data (from the 3 pages/parts of the form) there?

I do not need to phsyically see the data on the second page, could this be passed into a hidden field on the second page instead? and so on.

Thanks

Yes to all of your question above.

The example I posted it actually gives you every coding structure you need.

Yanhead
06-09-2003, 01:30 PM
Originally posted by Charles
If your form handling script is in Perl then use the CGI.pm module. All you need to do is generate hidden fields with the same names as the form fields you are trying to pass through. The module does the rest.

use CGI qw(:standard);
print header, start_html, start_form, hidden(-name=>'test1', -default=>'someDefault'), end_form, end_html;

unforunately, I do not write Perl (or any other server side coding) I was trying to pass the data from page to page using cookies which I think I might be able to manage.

Thanks

Charles
06-09-2003, 01:54 PM
Originally posted by Yanhead
unforunately, I do not write Perl (or any other server side coding) I was trying to pass the data from page to page using cookies which I think I might be able to manage.

Thanks That's a shame. Using JavaScript, cookies and a "mailto:" as the form action your form will fail for every user who doesn't use JavaScript, everyone that disables cookies and everyone who uses AOL. And you don't need to know much more about Perl than I've demonstrated to have something that actually works.

Yanhead
06-09-2003, 01:59 PM
Originally posted by Khalid Ali
Yes to all of your question above.

The example I posted it actually gives you every coding structure you need.

what would I need to change to make it write to a hidden field?

I'm getting

"GC02BASE=Tue Apr 29 14:03:24 UTC+0100 2003; GCLASTRUN=1051617398489; GColdrelativetimecookie=-4005511; GCSTRM01=/e15_otc/-4005511/e01_otc/1051617398489/e03_otc/1051617398489/; GCSTRMPR=513358006"

when I run try the form, does this look ok? shouldn't I see the data entered into the form amongst the above text?

Thanks for your time.

Khalid Ali
06-09-2003, 02:06 PM
You should.In the example I provided..thats exactly what happens.

You enter values in the form fields and the next page displays the
form field name = field value

if you need help in implemetation..
Then create your page following the code example provided.Then post the link here for me or someone else to see,so that one can help you in debugging your code.

Vladdy
06-09-2003, 02:07 PM
Why not put all the form on one page. You can section it into 3 divs and make "Tab" like interface to display one at a time. At least it will degrade gracefully and you will avoid quite a few headaches.
<script>
funciton selectSection(sn)
{ for(var i=1; i<4; i++)
document.getElementById('section'+i).style.display = (i==sn?'':'none');
return false;
}
</script>
<body onload="selectSection(1)">
<div id="tabs">
<a href="#section1" onclick="return selectSection(1)">Section 1</a>
<a href="#section2" onclick="return selectSection(2)">Section 2</a>
<a href="#section3" onclick="return selectSection(3)">Section 3</a>
</div>
<div id="formContent">
<form>
<div class="formSection" id="section1">
<!-- first "page" elements here -->
</div>
<div class="formSection" id="section2">
<!-- second "page" elements here -->
</div>
<div class="formSection" id="section3">
<!-- third "page" elements here -->
</div>
</form>
</div>

Yanhead
06-09-2003, 02:55 PM
Originally posted by Vladdy
Why not put all the form on one page. You can section it into 3 divs and make "Tab" like interface to display one at a time. At least it will degrade gracefully and you will avoid quite a few headaches.
<script>
funciton selectSection(sn)
{ for(var i=1; i<4; i++)
document.getElementById('section'+i).style.display = (i==sn?'':'none');
return false;
}
</script>
<body onload="selectSection(1)">
<div id="tabs">
<a href="#section1" onclick="return selectSection(1)">Section 1</a>
<a href="#section2" onclick="return selectSection(2)">Section 2</a>
<a href="#section3" onclick="return selectSection(3)">Section 3</a>
</div>
<div id="formContent">
<form>
<div class="formSection" id="section1">
<!-- first "page" elements here -->
</div>
<div class="formSection" id="section2">
<!-- second "page" elements here -->
</div>
<div class="formSection" id="section3">
<!-- third "page" elements here -->
</div>
</form>
</div>


excellent idea, it doesn't have to be on 3 seperate pages (The data from all three forms has got to be sent in 'one piece' though - which this solution would do)

I'm not having any luck with the above code, I'm getting a blank page when I preview it in a browser. Shouldn't I be seeing the 'Tabs'

what are divs?

Thanks

Vladdy
06-09-2003, 03:02 PM
I did not post a working page, just an idea for possible layout. You need to complete the HTML code and add CSS definitions to make things work right...

Yanhead
06-09-2003, 03:48 PM
Originally posted by Khalid Ali
You should.In the example I provided..thats exactly what happens.

You enter values in the form fields and the next page displays the
form field name = field value

if you need help in implemetation..
Then create your page following the code sxample provided.Then post the link here for me or someone else to see,so that one can help you in debugging your code.

In your example, why can't I see the source code of the second page

Khalid Ali
06-09-2003, 04:05 PM
I just checked the second page and it I can see the src ( I used NS6+)

Yanhead
06-09-2003, 04:40 PM
Originally posted by Khalid Ali
I just checked the second page and it I can see the src ( I used NS6+)


very strange, 'View source' is greyed out in IE on the second page of your example!

I just looked at it in Netscape7 and I can see it too.