mardi 27 septembre 2016

How to compare record in one table equal to another table using VBscript

My system require me to use VbScript

My Situation is
I have 2 table, named CoverTypes(coverID,coverName data) and InsuCover(selected CoverID and coverName data by user).

I want to display all the data in CoverTypes with checkbox (is checked) if the data is also in insuCover table, and unchecked if there is no same data

What I did so far is

  • My Query

    coverTypes.Open "SELECT * FROM preregister.coverType", conn, 1

    insuCover.Open "SELECT * FROM insuCover where insuranceReqId = '"& insFireReqID&"'",conn, 1

Code to Display

                                    <% Do While Not coverTypes.EOF%>
                                    <% if insuCover("coverId") = coverTypes("coverID") then%>
                                       <label id="coverID" name="coverNm"><%=coverTypes("coverNm")%></label>
                                       <input checked ="True" id="item_isSelected" name="item.isSelected" type="checkbox" value="<%=coverTypes("coverId")%>" /><br>
                                     <% else %>
                                       <label id="coverID" name="coverNm"><%=coverTypes("coverNm")%></label>
                                       <input id="item_isSelected" name="item.isSelected" type="checkbox" value="<%=coverTypes("coverId")%>" /><br>
                                    <% end if%>
                                <% coverTypes.MoveNext %>
                                <% Loop %>

The problem is
Currently only one checkbox is selected since I do not loop insuCover, but when I loop 2 table and compare, all the data get repeated many times.

How should I display all the data in CoverTypes and make the checkbox to true if the data is also present in insuCover table?

Thank you.




Aucun commentaire:

Enregistrer un commentaire