It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming JavaScript Forum

how scan by userjs ?

how scan by userjs ?

Postby pods on Wed Dec 30, 2009 3:31 pm

how may i'm check the checkbox in all company name =='Electronics' ?
page code
Code: Select all
<div class="item clearfix">
<div class="box1">     
   <input type="checkbox" name="chkIds" id="chk26671398"  value="26671398" />
</div>
<div style="margin-bottom:5px;">
   <a href="http://company1.com" target="_blank" class="company">Electronics</a>
</div>
</div>
<div class="item clearfix">
<div class="box1">     
   <input type="checkbox" name="chkIds" id="chk26671399"  value="26671399" />
</div>
<div style="margin-bottom:5px;">
   <a href="http://company2.com" target="_blank" class="company">Department</a>
</div>
</div>
pods
 
Posts: 1
Joined: Wed Dec 30, 2009 3:24 pm

Re: how scan by userjs ?

Postby harrierdh on Wed Dec 30, 2009 7:37 pm

Code: Select all
<script>
function checkthebox(obj) {
    var name = document.getElementById(obj.id).innerHTML;
   alert(name);
   if (name == "Electronics") {
       document.getElementById("chk26671398").checked = "true";
   }
}
</script>

    <div class="item clearfix">
    <div class="box1">     
       <input type="checkbox" name="chkIds" id="chk26671398"  value="26671398" />
    </div>
    <div style="margin-bottom:5px;">
       <a href="http://company1.com" target="_blank" class="company" id="company1" onClick="checkthebox(this)">Electronics</a>
    </div>
    </div>
    <div class="item clearfix">
    <div class="box1">     
       <input type="checkbox" name="chkIds" id="chk26671399"  value="26671399" />
    </div>
    <div style="margin-bottom:5px;">
       <a href="http://company2.com" target="_blank" class="company" id="company2" onClick="checkthebox(this)">Department</a>
    </div>
    </div>
harrierdh
50+ Club
 
Posts: 51
Joined: Wed Dec 16, 2009 7:04 pm

Re: how scan by userjs ?

Postby rangana on Wed Dec 30, 2009 9:58 pm

@harrierdh: What's missing on your code is that you forgot to "cancel" the links normal behavior. To do this, you can add: return false; on the function or after the function call.

Otherwise, it works perfect :wink:
User avatar
rangana
500+ Club
 
Posts: 935
Joined: Wed Feb 27, 2008 5:14 am
Location: Cebu City Philippines


Who is online

Users browsing this forum: No registered users and 12 guests