+ Reply to Thread
Results 1 to 5 of 5

Thread: Checkboxes in JavaScript in conjunction with Formmail

  1. #1
    Join Date
    Dec 2004
    Posts
    13

    Question Checkboxes in JavaScript in conjunction with Formmail

    I am running into a problem on a form that I am currently using. I am trying to find out what checkboxes are selected. I know that I can use an array and an index if all checkboxes are named the same, but in order for me to get the name of the checkbox selected to return in my formmail message, this would be impossible...

    I have a table in a form where you can select certain colors. I have named each checkbox with that color. This works nicely when formmail returns the name of the checkbox to me... I can see what the customer has selected. If I set each checkbox with the same name, I can not get the information I need. Do you see my problem? Maybe I am working at this from the wrong angle.

    Here is a portion of the html script I am using...This code is the beginning of a color chart.

    <td style="border-style:solid; border-width:1; text-align: center; vertical-align: top">
    <img border="0" src="images/Inks/Black.jpg" width="91" height="19">
    <div><font size="2">Black</font></div>
    <div><font size="2">&nbsp;</font></div>
    <div><input type="checkbox" name="Black_1" value=".001786667">
    <font size="2">Inside | Outside</font><input type="checkbox" name="Black_2" value=".001786667"></div>
    </td>
    <td style="border-style:solid; border-width:1; text-align: center; vertical-align: top">
    <img border="0" src="images/Inks/CG6.jpg" width="91" height="19">
    <div><font size="2" color="#008000">Cool Gray #6</font></div>
    <div><font size="2">&nbsp;</font></div>
    <div><input type="checkbox" name="CG6_1" value=".006146667">
    <font size="2">Inside | Outside</font><input type="checkbox" name="CG6_2" value=".006146667"></div>
    </td>


    Inside the JavaScript I have portions of code like this...

    if (document.estimateForm.Black_1.checked)
    { do something...}
    if (document.estimateForm.Black_2.checked)
    { do something...}
    if (document.estimateForm.CG6_1.checked)
    { do something...}
    if (document.estimateForm.CG6_2.checked)
    { do something...}

    when I go to view the page, I get an error stating that it is looking for a ).
    I have looked through the code and cannot for the life of me figure out what is missing.

    Can you see what I am doing wrong?

  2. #2
    Join Date
    Dec 2003
    Posts
    3,900

    Default Re: Checkboxes in JavaScript in conjunction with Formmail

    Hi,

    I see the why you have the names you've used - because the values are numbers, FormMail will show you the list of values if the checkbox names are the same instead of a list of colour names. Does that matter?

    However, what you haven't told me is what the actual problem is. With the checkbox names you have it should work and when the form is submitted, you'll get the list of fields that have been checked. What's the problem?

    With the missing ')', I have no idea - send me the URL and I can take a quick look. But that's just a matter of closely looking at the JavaScript code to find your error.
    Russell Robinson - Author of Tectite FormMail and FormMailDecoder
    http://www.tectite.com/

  3. #3
    Join Date
    Dec 2004
    Posts
    13

    Default Re: Checkboxes in JavaScript in conjunction with Formmail

    In the majority of the color names, the values are identical... therefore, I cannot rely on the value to get passed and be able to match it with the color selected.

    The problem I am having is more than likely syntax. For the first checkbox I had originally set an ' onClick="ink1=.001786667" ' function to the input type. This works great, until someone changes their mind and "un clicks it". The value will remain. I thought I might have to change directions and see if it was checked instead.

    As a second wrench to throw in, the values of all the checkboxes are being written to a database. If I rename them to be all the same, how will that affect what columns these values go into?

    ...unless I am totally braindead...

  4. #4
    Join Date
    Dec 2003
    Posts
    3,900

    Default Re: Checkboxes in JavaScript in conjunction with Formmail

    Hi,

    In the majority of the color names, the values are identical... therefore, I cannot rely on the value to get passed and be able to match it with the color selected.
    OK. So, with your current naming, you don't have that problem. Each checkbox has it's own field name and that tells you the colour.

    So, what's the problem with this current naming?

    As a second wrench to throw in, the values of all the checkboxes are being written to a database. If I rename them to be all the same, how will that affect what columns these values go into?
    FormMail lists the values of checkboxes that are the same name. So, this won't be helpful with numeric values.

    So, the current naming you have looks fine. Again, what's the problem?
    Russell Robinson - Author of Tectite FormMail and FormMailDecoder
    http://www.tectite.com/

  5. #5
    Join Date
    Dec 2004
    Posts
    13

    Default Re: Checkboxes in JavaScript in conjunction with Formmail

    I think I found my problem.

    Some of the fields were named by a number (i.e. 021_1)

    when I ran it through the script I was getting an error. I started lining out my code and it worked up to the point where the inputs were named by numbers. I changed the names to have an alpha prefix and the code worked.

    I didn't have a problem until I went to see if the boxes were "checked".

    (Aah, Grasshopper, much to learn...)

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Javascript image reload for image verify
    By swaz in forum FormMail Subscription Support
    Replies: 4
    Last Post: 28-Aug-2006, 01:24 AM
  2. something not working, checkboxes
    By ScottR in forum Community Support
    Replies: 1
    Last Post: 13-Feb-2006, 10:22 PM
  3. Condition - restrict maximum checkboxes
    By tvulucy in forum FormMail Subscription Support
    Replies: 3
    Last Post: 22-Aug-2005, 09:42 PM
  4. new code for multiple checkboxes
    By nevdev in forum FormMail Subscription Support
    Replies: 2
    Last Post: 15-Jan-2005, 11:39 PM
  5. Javascript and formmail: drop down list
    By bwv in forum FormMail Subscription Support
    Replies: 4
    Last Post: 05-Nov-2004, 11:18 PM

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