Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New to the CF scene
    Join Date
    Oct 2002
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile Email only textboxes with responses?

    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!

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Not debugged, but should be close...
    Code:
    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);">
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”

  • #3
    New to the CF scene
    Join Date
    Oct 2002
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    What do I need to edit

    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!

  • #4
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Do you have the page online someplace? So I can look at the source code?
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”

  • #5
    New to the CF scene
    Join Date
    Oct 2002
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Link

    This is the link:


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

    Any help is GREATLY appreciated!

  • #6
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You didn't add the function call to the onSubmit event! Because of your FrontPage validator function, let's do it this way
    Code:
    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">
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”

  • #7
    New to the CF scene
    Join Date
    Oct 2002
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Please explain

    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....

  • #8
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well, typically scripting goes in the <HEAD>, but any script within a function can pretty much be placed anywhere.
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •