Results 1 to 5 of 5

Thread: Ignore 'CC' field in Form Post if left 'blank'

  1. #1
    Join Date
    Oct 2005
    Location
    Liverpool, UK
    Posts
    87
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Question Ignore 'CC' field in Form Post if left 'blank'

    I'd like to give the user an option of specifying a value for a 'cc' email address on a form.
    What I'd like to do is to be able to see if a value has been entered into this field. If it is blank then I need the code to ignore the 'cc' declaration.

    I cannot change the mail.asp we're using - if I declare the cc field and submit a blank then this generates a error email (and grief for me! )

    Can anyone help please?

    Thanks in advance,

    N.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Can you do a:

    Code:
    if (cc!=='')
    code here to declare the cc field
    Where cc is the value of a text input where the user enters the cc addresses if desired.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Oct 2005
    Location
    Liverpool, UK
    Posts
    87
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Question

    So, given that I'm using "mailto" and "mailcc" as the two holders, would it look something like this:

    -----------------------------------------------------------
    <form name="example" method="post" action="/lib/common/mailing.asp">
    <input type="text" name="cc">
    <input type="hidden" name="mailto" value="my.usual@email.co.uk">

    if (cc!=='') <input type="hidden" name="mailcc" value="cc">

    ... << the main form elements here >> ...

    <input type="Submit" value="Submit">
    -----------------------------------------------------------

    I am not familiar with the use of IF statements within HTML yet (this will help me learn!) but I'm sure I'm not doing this right! Do I need to enclose the overall statement in brackets or something?

    Thanks again for your help,

    N.

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    If cannot generally be used in HTML (with specific exceptions, this not being one of them). It can generally be used in javascript, try this:

    Code:
    <form name="example" method="post" action="/lib/common/mailing.asp">
    <script type="text/javascript">
    function createCC(el){
    if (el.value!==''&&!document.getElementById('cctestid')){
    var theCC=document.createElement('input');
    theCC.name='mailcc';
    theCC.value=el.value;
    theCC.type='hidden';
    theCC.id='cctestid';
    el.parentNode.appendChild(theCC);
    }
    else if (el.value!=='')
    document.getElementById('cctestid').value=el.value;
    else if (document.getElementById('cctestid'))
    document.getElementById('cctestid').parentNode.removeChild(document.getElementById('cctestid'));
    }
    </script>
    <input type="text" name="cc" onchange="createCC(this);">
    <input type="hidden" name="mailto" value="my.usual@email.co.uk">
    
    
    ... << the main form elements here >> ...
    
    <input type="Submit" value="Submit">
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Oct 2005
    Location
    Liverpool, UK
    Posts
    87
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Thumbs up

    That works just fine!!

    Thanks for the help on this one - really useful !!

    Cheers,

    N.

Bookmarks

Posting Permissions

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