...

View Full Version : Email only textboxes with responses?



BrightEyes
10-31-2002, 06:09 PM
I am trying to create a form that only sends the data from textboxes the user has typed in and does not report the empty fields.

Example:
A grocery list of 50 items is shown. The "customer" marks the checkboxes of the desired items and then indicates the quantity of each in the corresponding textbox. I can get the checkboxes that are marked to report, but it also lists every single textbox whether it has been filled in or not!

Can anyone direct me to the script that will report the findings "only if" that particular textbox has been filled? Thanks in advance!

beetle
10-31-2002, 06:51 PM
Not debugged, but should be close...
function disableEmpty(f) {
for (var i=0; i<f.elements.length; i++) {
var e = f.elements[i];
if (e.type.toUpperCase() != "TEXT") break;
if (/^\s*$/.test(e.value))
e.disabled = true;
}
return true;
}

<form onSubmit="return disableEmpty(this);">

BrightEyes
10-31-2002, 07:14 PM
Thank you so much for responding....

I tried putting the script straight into the body, but it did not change the outcome of the email (all of the textboxes are still listed in the email). I did not receive error messages and the site performed as normal.

What elements of the code do I need to change in order to personalize it for the textboxes on this particular form? Thanks in advance!

beetle
10-31-2002, 07:29 PM
Do you have the page online someplace? So I can look at the source code?

BrightEyes
10-31-2002, 07:31 PM
This is the link:


http://www.rayandsandysbigstar.com/order_form_boxes.htm

Any help is GREATLY appreciated!

beetle
10-31-2002, 08:36 PM
You didn't add the function call to the onSubmit event! Because of your FrontPage validator function, let's do it this way
function disableEmpty(f) {
for (var i=0; i<f.elements.length; i++) {
var e = f.elements[i];
if (e.type.toUpperCase() != "TEXT") break;
if (/^\s*$/.test(e.value))
e.disabled = true;
}
// removed
}

<form method="POST" name="FrontPage_Form1" action="_vti_bin/shtml.dll/order_form_boxes.htm" onsubmit="disableEmpty(this);return FrontPage_Form1_Validator(this)" webbot-action="--WEBBOT-SELF--" language="JavaScript">

BrightEyes
10-31-2002, 09:18 PM
Please forgive my confusion because my brain is evidently not thinking all the way.....

Where do I need to add the:

---------------------------------------
function disableEmpty(f) {
for (var i=0; i&lt;f.elements.length; i++) {
var e = f.elements[i];
if (e.type.toUpperCase() != "TEXT") break;
if (/^\s*$/.test(e.value))
e.disabled = true;
}
// removed
}
---------------------------------------

because I have evidently not placed it correctly. Thanks for your patience....

beetle
10-31-2002, 09:33 PM
Well, typically scripting goes in the <HEAD>, but any script within a function can pretty much be placed anywhere.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum