Click to See Complete Forum and Search --> : copy values to hidden form fields


feafee
05-09-2003, 11:07 AM
Ok, I've got a question that I hope someone can help me with. I have a page named customerinfo where people can input their info, then click on a next button. The next button takes them to a productinfo page. The button worked until I added some code to the function. I want the values from the first few fields to be copied to the hidden form fields in my topframe page. This is what the function looks like now:

function nextForm() {
parent.topframe.document.hiddenElements.name.value
= document.customerInfo.name.value;
parent.topframe.document.hiddenElements.address.value
= document.customerInfo.address.value;
parent.topframe.document.hiddenElements.city.value
= document.customerInfo.city.value;
parent.topframe.document.hiddenElements.state.value
= document.customerInfo.state.value;
parent.topframe.document.hiddenElements.zip.value
= document.customerInfo.zip.value;
parent.topframe.document.hiddenElements.email.value
= document.customerInfo.email.value;
parent.topframe.document.hiddenElements.password.value
= document.customerInfo.password.value;

if (document.customerInfo.platform[0].checked == true)
parent.topframe.document.hiddenElements.platform.value
= document.customerInfo.platform[0].value;

if (document.customerInfo.platform[1].checked == true)
parent.topframe.document.hiddenElements.platform.value
= document.customerInfo.platform[1].value;

if (document.customerInfo.platform[2].checked == true)
parent.topframe.document.hiddenElements.platform.value
= document.customerInfo.platform[2].value;

if (document.customerInfo.platform[3].checked == true)
parent.topframe.document.hiddenElements.platform.value
= document.customerInfo.platform[3].value;

if (document.customerInfo.platform[4].checked == true)
parent.topframe.document.hiddenElements.platform.value
= document.customerInfo.platform[4].value;

if (document.customerInfo.platform[5].checked == true)
parent.topframe.document.hiddenElements.platform.value
= document.customerInfo.platform[5].value;

if (document.customerInfo.wp.checked == true)
parent.topframe.document.hiddenElements.wp.value = true;

if (document.customerInfo.ss.checked == true)
parent.topframe.document.hiddenElements.ss.value = true;

if (document.customerInfo.db.checked == true)
parent.topframe.document.hiddenElements.db.value = true;

if (document.customerInfo.gr.checked == true)
parent.topframe.document.hiddenElements.gr.value = true;

if (document.customerInfo.pr.checked == true)
parent.topframe.document.hiddenElements.pr.value = true;

parent.topframe.document.hiddenElements.location.value =
document.customerInfo.location.value;

parent.topframe.document.hiddenElements.comments.value =
document.customerInfo.comments.value;

if (parent.topframe.document.hiddenElements.name.value == ""
|| parent.topframe.document.hiddenElements.address.value == ""
|| parent.topframe.document.hiddenElements.city.value == ""
|| parent.topframe.document.hiddenElements.state.value == ""
|| parent.topframe.document.hiddenElements.zip.value == ""
|| parent.topframe.document.hiddenElements.password.value == "")
alert("You must fill in the name, address, city, state, zip, and password fields.");

else


location.href="ProductInfo.html";
}


Any idea what I'm doing wrong on this function?

Thanks so much,
Jenny

fakeName
05-09-2003, 12:21 PM
It might help to post the two forms

feafee
05-09-2003, 01:27 PM
ok, here is the code from all the files. First, here is the topframe file:

<HTML>
<BODY>
<H1>Product Registration</H1>
<FORM NAME="hiddenElements">
<INPUT TYPE="hidden" NAME="name">
<INPUT TYPE="hidden" NAME="address">
<INPUT TYPE="hidden" NAME="city">
<INPUT TYPE="hidden" NAME="state">
<INPUT TYPE="hidden" NAME="zip">
<INPUT TYPE="hidden" NAME="email">
<INPUT TYPE="hidden" NAME="password">
<INPUT TYPE="hidden" NAME="platform">
<INPUT TYPE="hidden" NAME="wp" VALUE=false>
<INPUT TYPE="hidden" NAME="ss" VALUE=false>
<INPUT TYPE="hidden" NAME="db" VALUE=false>
<INPUT TYPE="hidden" NAME="gr" VALUE=false>
<INPUT TYPE="hidden" NAME="pr" VALUE=false>
<INPUT TYPE="hidden" NAME="comments">
<INPUT TYPE="hidden" NAME="location">
<INPUT TYPE="hidden" NAME="serial">
<INPUT TYPE="hidden" NAME="date">
<INPUT TYPE="hidden" NAME="where">
</FORM>
</BODY>
</HTML>

And this is the customerinfo file:

<HTML>
<HEAD>
<TITLE>Customer Information</TITLE>
<SCRIPT LANGUAGE="JavaScript">
<!-- HIDE FROM INCOMPATIBLE BROWSERS

function confirmReset() {
var resetForm = confirm("Are you sure you want to reset the form?");
if (resetForm == true)
return true;
return false;
}
function nextForm() {
parent.topframe.document.hiddenElements.name.value =
document.customerInfo.name.value;
parent.topframe.document.hiddenElements.address.value =
document.customerInfo.address.value;
parent.topframe.document.hiddenElements.city.value =
document.customerInfo.city.value;
parent.topframe.document.hiddenElements.state.value =
document.customerInfo.state.value;
parent.topframe.document.hiddenElements.zip.value =
document.customerInfo.zip.value;
parent.topframe.document.hiddenElements.email.value =
document.customerInfo.email.value;
parent.topframe.document.hiddenElements.password.value =
document.customerInfo.password.value;
if (document.customerInfo.platform[0].checked == true)
parent.topframe.document.hiddenElements.platform.value =
document.customerInfo.platform[0].value;
if (document.customerInfo.platform[1].checked == true)
parent.topframe.document.hiddenElements.platform.value =
document.customerInfo.platform[1].value;
if (document.customerInfo.platform[2].checked == true)
parent.topframe.document.hiddenElements.platform.value =
document.customerInfo.platform[2].value;
if (document.customerInfo.platform[3].checked == true)
parent.topframe.document.hiddenElements.platform.value =
document.customerInfo.platform[3].value;
if (document.customerInfo.platform[4].checked == true)
parent.topframe.document.hiddenElements.platform.value =
document.customerInfo.platform[4].value;
if (document.customerInfo.platform[5].checked == true)
parent.topframe.document.hiddenElements.platform.value =
document.customerInfo.platform[5].value;
if (document.customerInfo.wp.checked == true)
parent.topframe.document.hiddenElements.wp.value = true;
if (document.customerInfo.ss.checked == true)
parent.topframe.document.hiddenElements.ss.value = true;
if (document.customerInfo.db.checked == true)
parent.topframe.document.hiddenElements.db.value = true;
if (document.customerInfo.gr.checked == true)
parent.topframe.document.hiddenElements.gr.value = true;
if (document.customerInfo.pr.checked == true)
parent.topframe.document.hiddenElements.pr.value = true;
parent.topframe.document.hiddenElements.location.value =
document.customerInfo.location.value;
parent.topframe.document.hiddenElements.comments.value =
document.customerInfo.comments.value;
if (parent.topframe.document.hiddenElements.name.value == ""
|| parent.topframe.document.hiddenElements.address.value == ""
|| parent.topframe.document.hiddenElements.city.value == ""
|| parent.topframe.document.hiddenElements.state.value == ""
|| parent.topframe.document.hiddenElements.zip.value == ""
|| parent.topframe.document.hiddenElements.password.value == "")
alert("You must fill in the name, address, city, state, zip, and password fields.");
else
location.href="ProductInfo.html";
}

//STOP HIDING FROM INCOMPATIBLE BROWSERS -->
</SCRIPT>
</HEAD>

<BODY>
<H3>Customer Information</H3>
<FORM NAME="customerInfo" onReset="return confirmReset();">

<P>Name<BR>
<INPUT TYPE="text" NAME="name" SIZE=50></P>
<P>Address<BR>
<INPUT TYPE="text" NAME="address" SIZE=50></P>
<P>City, State Zip<BR>
<INPUT TYPE="text" NAME="city" SIZE=38>
<INPUT TYPE="text" NAME="state" SIZE=2 MAXLENGTH=2>
<INPUT TYPE="text" NAME="ZIP" SIZE=5 MAXLENGTH=5></P>
<P>E-Mail<BR>
<INPUT TYPE="text" NAME="email" SIZE=50></P>

<P>Enter a password, which you will need when you call technical support<BR>
<INPUT TYPE="password" NAME="password" SIZE=50></P>

<P>What platform do you use?<BR>
<INPUT TYPE="radio" NAME="platform" VALUE="win2K">Windows 2000
<INPUT TYPE="radio" NAME="platform" VALUE="win95-98">Windows 95/98
<INPUT TYPE="radio" NAME="platform" VALUE="winnt">Windows NT
<INPUT TYPE="radio" NAME="platform" VALUE="winme">Windows ME
<INPUT TYPE="radio" NAME="platform" VALUE="unix">UNIX
<INPUT TYPE="radio" NAME="platform" VALUE="mac">Macintosh</P>

<P>What types of software do you use (check all that apply)?<BR>
<INPUT TYPE="checkbox" NAME="wp" VALUE="wp">Word Processing<BR>
<INPUT TYPE="checkbox" NAME="ss" VALUE="ss">Spreadsheets<BR>
<INPUT TYPE="checkbox" NAME="db" VALUE="db">Database<BR>
<INPUT TYPE="checkbox" NAME="gr" VALUE="gr">Graphics/CAD<BR>
<INPUT TYPE="checkbox" NAME="pr" VALUE="pr">Programming</P>

<P>Where will you use this product?
<SELECT NAME="location">
<OPTION VALUE="work">Work
<OPTION VALUE="school">School
<OPTION VALUE="home">Home
<OPTION VALUE="home_office">Home Office
</SELECT></P>

<P>Comments<BR>
<TEXTAREA NAME="comments" COLS=40 ROWS=5>
Enter any additional comments here
</TEXTAREA></P>

<P><INPUT TYPE="reset">
<INPUT TYPE="button" NAME="next" VALUE=" Next "
onClick="nextForm()"></P>

</FORM>
</BODY>
</HTML>

and here is the productinfo file code:

<HTML>
<HEAD>
<TITLE>Product Information</TITLE>
<SCRIPT>
function confirmReset() {
var resetForm = confirm(
"Are you sure you want to reset the form?");
if (resetForm == true)
return true;
return false;
}
</SCRIPT>
</HEAD>
<BODY>
<H3>Product Information</H3>
<FORM NAME="productInfo" onReset="return confirmReset();">
<P><B>Serial Number</B><BR>
<INPUT TYPE="text" NAME="serial" SIZE=50></P>
<P><B>Date Purchased</B><BR>
<INPUT TYPE="text" NAME="date" SIZE=50></P>
<P><B>Where did you purchase this product?</B><BR>
<INPUT TYPE="radio" NAME="where" VALUE="retail">Retail Store<BR>
<INPUT TYPE="radio" NAME="where" VALUE="catalog_mail">Catalog/Mail Order<BR>
<INPUT TYPE="radio" NAME="where" VALUE="internet">Internet Transaction<BR>
<INPUT TYPE="radio" NAME="where" VALUE="other">Other<BR>
<P><INPUT TYPE="reset">
<INPUT TYPE="submit">
</P>
</FORM>
</BODY>
</HTML>

I want to open them using a framed page named productregistration. Here is the code for that page incase it might be helpful:

<HTML>
<HEAD>
<TITLE>Product Registration</TITLE>
</HEAD>

<FRAMESET ROWS="60, *">
<FRAME SRC="TopFrame.html" NAME="topframe" SCROLLING=no>
<FRAME SRC="CustomerInfo.html" NAME="bottomframe">
</FRAMESET>


</HTML>

Hope this is enough info. Thanks again!

feafee
05-11-2003, 10:57 PM
An error has occurred in the script on this page.

Line: 22
Char: 2
Error: 'document.customerInfo.zip.value' is null or not an object
Code: 0


Say, is there something wrong with that line?

feafee
05-11-2003, 11:12 PM
I had capatalized zip when I shouldn't have one time. Hee, hee. Thanks so much for pointing out that error message thing. Took me a little while to decide to search for the word zip since it was in the error line. Very happy to have it working now.

Thank You So So Much!

Jenny

feafee
05-16-2003, 10:45 AM
Ok, now that I got the customerinfo file working I can go to my next page named productinfo. But when I click the submit button, it does not submit. The error message wasn't much help on this one. Any ideas would be greatly appreciated.

This is the productinfo file:

<HTML>
<HEAD>
<TITLE>Product Information</TITLE>
<SCRIPT>

function submitForm() {
parent.topframe.document.hiddenElements.serial.value =
document.productInfo.serial.value;
parent.topframe.document.hiddenElements.date.value =
document.productInfo.date.value;

if (document.productInfo.where[0].checked == true)
parent.topframe.document.hiddenElements.where.value =
document.platformInfo.where[0].value;
if (document.productInfo.where[1].checked == true)
parent.topframe.document.hiddenElements.where.value =
document.platformInfo.where[1].value;
if (document.productInfo.where[2].checked == true)
parent.topframe.document.hiddenElements.where.value =
document.platformInfo.where[2].value;
if (document.productInfo.where[3].checked == true)
parent.topframe.document.hiddenElements.where.value =
document.platformInfo.where[3].value;

if (
parent.topframe.document.hiddenElements.serial.value
== ""||
parent.topframe.document.hiddenElements.date.value
== "") {
alert(
"You must fill in the date and serial number.");
return false;
}


else {
parent.topframe.document.hiddenElements.submit();
return false;
}

}

function confirmReset() {
var resetForm = confirm("Are you sure you want to reset the form?");
if (resetForm == true)
return true;
return false;
}

</SCRIPT>
</HEAD>
<BODY>
<H3>Product Information</H3>
<FORM NAME="productInfo" onReset="return confirmReset();" onSubmit="return submitForm();">
<P><B>Serial Number</B><BR>
<INPUT TYPE="text" NAME="serial" SIZE=50></P>
<P><B>Date Purchased</B><BR>
<INPUT TYPE="text" NAME="date" SIZE=50></P>
<P><B>Where did you purchase this product?</B><BR>
<INPUT TYPE="radio" NAME="where" VALUE="retail">Retail Store<BR>
<INPUT TYPE="radio" NAME="where" VALUE="catalog_mail">Catalog/Mail Order<BR>
<INPUT TYPE="radio" NAME="where" VALUE="internet">Internet Transaction<BR>
<INPUT TYPE="radio" NAME="where" VALUE="other">Other<BR>
<P><INPUT TYPE="reset">
<INPUT TYPE="submit">
</P>
</FORM>
</BODY>
</HTML>

and this is the topframe:

<HTML>
<BODY>
<H1>Product Registration</H1>
<FORM NAME="hiddenElements" ACTION="mailto:feafee@aaip.net" METHOD="post" ENCTYPE="text/plain">
<INPUT TYPE="hidden" NAME="name">
<INPUT TYPE="hidden" NAME="address">
<INPUT TYPE="hidden" NAME="city">
<INPUT TYPE="hidden" NAME="state">
<INPUT TYPE="hidden" NAME="zip">
<INPUT TYPE="hidden" NAME="email">
<INPUT TYPE="hidden" NAME="password">
<INPUT TYPE="hidden" NAME="platform">
<INPUT TYPE="hidden" NAME="wp" VALUE=false>
<INPUT TYPE="hidden" NAME="ss" VALUE=false>
<INPUT TYPE="hidden" NAME="db" VALUE=false>
<INPUT TYPE="hidden" NAME="gr" VALUE=false>
<INPUT TYPE="hidden" NAME="pr" VALUE=false>
<INPUT TYPE="hidden" NAME="comments">
<INPUT TYPE="hidden" NAME="location">
<INPUT TYPE="hidden" NAME="serial">
<INPUT TYPE="hidden" NAME="date">
<INPUT TYPE="hidden" NAME="where">
</FORM>
</BODY>
</HTML>

The error message says that the problem is line 33 char 2, but I can't find any problems with that line.
This is the line it says is the problem:
document.platformInfo.where

Thanks so much,

Jenny

feafee
05-17-2003, 11:59 AM
Thank you so very much!

Jenny