Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. Salesforce
  3. Question
Salesforce

Why is Search while Type functionality on VFP not working as expected between apex: tab transition?

Asked by Anne Bell Aug 16, 2021 1.2K views 1 answer
Share

About this question

 I have 2 apex:tabs (Primary Tab, Secondary Tab) in visualforce page which shows a table of accounts list. I have a custom script for "search-while typing" functionality with belowscript. //VFP

[removed]                  <input type="text" id="inputAccountName" onkeyup="searchByAccountName()" placeholder="Search by Account..." title="Type in an Account Name"/> <!-------- Primary Tab --------> <!-- *** Primary Detail Mode*** -->

Loading.... Please Wait...
{!a.Acc.name}
<!-------- Secondary Tab --------> <!-- *** Secondary Detail Mode*** -->
Loading.... Please Wait...
{!a.Acc.name}

        

    

    [removed]

        // Account Search script

        function searchByAccountName() {

            var input, filter, table, tr, td, i, txtValue, multipletables;

            input = document.getElementById("inputAccountName");

            filter = input.value.toUpperCase();

            multipletables = ["schTablePrimaryDetail","schTable1PrimaryEdit","schTableSecondaryDetail","schTable1SecondaryEdit"];

            var x = multipletables.length;

            for (var k = 0; k < multipletables>

                table = document.getElementById(multipletables[k]);

                tr = table.getElementsByTagName("tr");

                for (i = 1; i < tr>

                    td = tr[i].getElementsByTagName("td")[0];

                    if (td) {

                    txtValue = td.textContent || td.innerText;

                        if (txtValue.toUpperCase().indexOf(filter) > -1) {

                            tr[i].style.display = "";

                        } else {

                            tr[i].style.display = "none";

                        }

                    }


                }

            }

        }

    [removed]

VFP with input text box on top

The functionality works just fine on Primary Tab where the accountName typed in the input "text" would show the corresponding account from the list of accounts with in the table. However it wont work on Secondary Tab and I'm unable to figure out/ debug what went wrong where the functionality won't work when switched to other tab. Please let me know what i'm missing here. Thanks in advance!

enter image description here


Why is Search while Type functionality not working as expected between apex tab transitions?

Your answer

1 Answer

More Salesforce discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest Salesforce Blogs

Guides, tips and career advice on Salesforce from JanBask experts.