This discussion is archived
8 Replies Latest reply: Nov 15, 2012 1:42 PM by 738277 RSS

Tabluar form doesn't submit when JS buttons are used.....

738277 Newbie
Currently Being Moderated
Hello Experts,
--- In short
I have a tabular form with check boxes, when I use javascript button to “check all” buttons and Submit the form, it won’t update the table rows. But, when I check/uncheck the boxes manually, and submit the form then it updates the table rows. Why is this? Is there any solution? I need that “Check All” button.

Thanks for your time,

DK
  • 1. Re: Tabluar form doesn't submit when JS buttons are used.....
    Shunt Pro
    Currently Being Moderated
    Hi DK

    Without more information it's hard to know what the problem is.

    This always works for me, perhaps you could try it and see if it works:

    Add the following to the column heading:
    <input type="checkbox" onclick="$f_CheckFirstColumn(this)">
    Or if it's a tabular form:

    http://www.simonhunt.blogspot.co.uk/2011/10/adjusting-interactive-report-column.html

    Alternatively, can you post the javascript function you're using so we can look at it.

    Cheers

    Shunt
  • 2. Re: Tabluar form doesn't submit when JS buttons are used.....
    738277 Newbie
    Currently Being Moderated
    Thanks Shunt for your time, and reply. I will try your suggestion. Below is the clear explanation of what I am doing and will also post the js code......

    I am creating a tabular form where I have to update the availability of two items by date.
    ------Date --------- Item 1 -------- Item 2
    03-16-2012 Y N

    like this I have to create a form with check boxes. Checked (Y), un checked (N) should be inserted. He first select 'Year' and 'Month' then fills the forms and submits it to update the records in the database.

    Now I addition to this I have to put three buttons
    "Clear All" -- clears all the check boxes
    "Populate Weekdays" --- This populates all the weekdays.
    "Reset" --- this rests the form with existing database values.

    I did all the coding and report work all fine except: When I use "Clear All" or "Populate Weekdays" button and Submit the form, its not updating the table. Instead if I check/uncheck manually and Submit it, it updates the table. Why is this? How can I solve it?

    Thanks once again.
  • 3. Re: Tabluar form doesn't submit when JS buttons are used.....
    738277 Newbie
    Currently Being Moderated
    Below is the javascript code for Clear All button.....I said "when clicked" redirect to url, in the url i called this js function.
    function clearcb(){
    var wkday = document.getElementsByName('f02_NOSUBMIT');
    var bizday = document.getElementsByName('f03_NOSUBMIT');
    var errStr = '';

    for (var i = 0; i <= wkday.length -1; i++){
    if (wkday.type == "checkbox")
                   {
                        wkday[i].checked = false;
                   }
    }

    for (var j = 0; j <= bizday.length -1; j++){
    if (bizday[j].type == "checkbox")
                   {
                        bizday[j].checked = false;
                   }
    }

    if (errStr != ''){
    errStr = errStr.substr(0,errStr.length - 1); /* Removing the last comma */
    alert ('The row(s) ' + errStr + ' must include ...');
    return(false);
    } else {
    return(true);
    }
    }
  • 4. Re: Tabluar form doesn't submit when JS buttons are used.....
    Shunt Pro
    Currently Being Moderated
    Hi

    It's sounds like your javascript function is causing the page to error and the doSubmit is then not working.

    I'm afraid I dont deal in JS anymore so can't immediately see the issue with your functions. In JQuery I would use functions like this:
    function checkAll() {
       $("[type='checkbox']").each(function() {
          $(this).attr("checked", "checked")
       });
    }
    
    function unCheckAll() {
       $("[type='checkbox']").each(function() {
          $(this).removeAttr('checked');
       });
    }
    
    function checkToggle() {
       $("[name='f01']").each(function() {
          $(this).attr("checked", !$(this).attr("checked"))
       });
    }
    I hope it helps

    Shunt
  • 5. Re: Tabluar form doesn't submit when JS buttons are used.....
    738277 Newbie
    Currently Being Moderated
    Thanks Shunt,

    This is not working......
  • 6. Re: Tabluar form doesn't submit when JS buttons are used.....
    738277 Newbie
    Currently Being Moderated
    Some thing I want to stress is -

    When I use JavaScript to check/uncheck the boxes, and submit the form its not updating the table......whereas when I check/uncheck the boxes manually and submit the form it updates the table........

    there is some thing happening when I check/uncheck the box manually......there is an event
    onclick="if (this.checked) {apex.jQuery('#f02_0004').val('Y');} else {apex.jQuery('#f02_0004').val('N');}"
    ....what does this mean...

    Thanks for your time,

    DK
  • 7. Re: Tabluar form doesn't submit when JS buttons are used.....
    Nicolette Expert
    Currently Being Moderated
    DK

    >
    there is some thing happening when I check/uncheck the box manually......there is an event
    onclick="if (this.checked) {apex.jQuery('#f02_0004').val('Y');} else {apex.jQuery('#f02_0004').val('N');}"
    ....what does this mean...
    This means that you are using a tabular form and simple checkbox as display type for the column.

    With a normal HTML checkbox only the checked values are stored in the array. Because this wasn't really clear and was differend from the other input types the apex development team came up with the simple checkbox.

    It displays as a checkbox but the array for the column is based on an hidden item. In your case f02.
    The code
    if (this.checked) {apex.jQuery('#f02_0004').val('Y');} else {apex.jQuery('#f02_0004').val('N');} 
    Means if the checkbox is clicked update the corresponding hidden item accordingly.

    In your javascript that sets the checkbox either set the value of the hidden item as well. Or trigger the onclick event for the checkbox.

    Nicolette
  • 8. Re: Tabluar form doesn't submit when JS buttons are used.....
    738277 Newbie
    Currently Being Moderated
    Thanks Nicolette,

    I will try it and let you know. For now I got to do some other reports, so it takes some time for me to test this......

    Thanks and regards,

    DK

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points