Jump to content
UBot Underground

How do you check multiple check boxes within a table that has a unique ID amoungst other tables


Recommended Posts

HI Experts

 

I need some assistance.

Been sitting for hours trying to figure out how to do this.

 

I have 3 tables with ids. (id="table_1")

I need to check all the check boxes in say id="table_2" but not in id="table_1" or id="table_3" before a form is submitted.

 

 

Does anyone know how this can be done?

Any help would be appreciated

 

Thanks in advance for any suggestions

 

example

 

<table class="info_table" id="table_1" style="margin-bottom: 1em; display: none">

       <tr>
            <td><input name="themes[84412]" type="hidden" value="f"><input id="themes_84412" name="themes[84412]" onclick="check_total_silos(this);" type="checkbox" value="t"></td>
            <td>

      </tr>

</table>

 

<table class="info_table" id="table_2" style="margin-bottom: 1em; display: none">

        <tr>
            <td><input name="themes[84413]" type="hidden" value="f"><input id="themes_84413" name="themes[84413]" onclick="check_total_silos(this);" type="checkbox" value="t"></td>
            <td>

        </tr>

        <tr>
            <td><input name="themes[84415]" type="hidden" value="f"><input id="themes_84415" name="themes[84415]" onclick="check_total_silos(this);" type="checkbox" value="t"></td>
            <td>

        </tr>

        <tr>
            <td><input name="themes[84418]" type="hidden" value="f"><input id="themes_84418" name="themes[84418]" onclick="check_total_silos(this);" type="checkbox" value="t"></td>
            <td>

        </tr>

</table>

 

<table class="info_table" id="table_3" style="margin-bottom: 1em; display: none">

         <tr>
            <td><input name="themes[84414]" type="hidden" value="f"><input id="themes_84414" name="themes[84414]" onclick="check_total_silos(this);" type="checkbox" value="t"></td>
            <td>

         </tr>

</table>

Link to post
Share on other sites

Here's one way you can do it:

(what the following example is doing is first scraping the HTML of the target table, then it scrapes all of the checkbox ID's into a list, and then loops through that list checking each one)

 

Enjoy!

load html("<table class=\"info_table\" id=\"table_1\" style=\"margin-bottom: 1em; display: block\">
       <tr>
            <td><input name=\"themes[84412]\" type=\"hidden\" value=\"f\"><input id=\"themes_84412\" name=\"themes[84412]\" onclick=\"check_total_silos(this);\" type=\"checkbox\" value=\"t\"></td>
            <td>
      </tr>
</table>
 
<table class=\"info_table\" id=\"table_2\" style=\"margin-bottom: 1em; display: block\">
        <tr>
            <td><input name=\"themes[84413]\" type=\"hidden\" value=\"f\"><input id=\"themes_84413\" name=\"themes[84413]\" onclick=\"check_total_silos(this);\" type=\"checkbox\" value=\"t\"></td>
            <td>
        </tr>
        <tr>
            <td><input name=\"themes[84415]\" type=\"hidden\" value=\"f\"><input id=\"themes_84415\" name=\"themes[84415]\" onclick=\"check_total_silos(this);\" type=\"checkbox\" value=\"t\"></td>
            <td>
        </tr>
        <tr>
            <td><input name=\"themes[84418]\" type=\"hidden\" value=\"f\"><input id=\"themes_84418\" name=\"themes[84418]\" onclick=\"check_total_silos(this);\" type=\"checkbox\" value=\"t\"></td>
            <td>
        </tr>
</table>
 
<table class=\"info_table\" id=\"table_3\" style=\"margin-bottom: 1em; display: block\">
         <tr>
            <td><input name=\"themes[84414]\" type=\"hidden\" value=\"f\"><input id=\"themes_84414\" name=\"themes[84414]\" onclick=\"check_total_silos(this);\" type=\"checkbox\" value=\"t\"></td>
            <td>
         </tr>
</table>")
set(#table_id, "table_2", "Global")
set(#focus_on_this_table, $scrape attribute(<id=#table_id>, "outerhtml"), "Global")
clear list(%checkbox_ids)
add list to list(%checkbox_ids, $find regular expression(#focus_on_this_table, "(?<=id\\=\\\").+(?=\\\"\\ name)"), "Delete", "Global")
loop($list total(%checkbox_ids)) {
    change checkbox(<id=$next list item(%checkbox_ids)>, "Checked")
}

checkbox_example.ubot

  • Like 1
Link to post
Share on other sites
  • 3 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...