Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Old 12-30-2009, 10:38 AM how scan by userjs ?
Junior Talker

Posts: 1
Name: pave
Trades: 0
how may i'm check the checkbox in all company name =='Electronics' ?
page code
Code:
<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 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 12-30-2009, 03:04 PM Re: how scan by userjs ?
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Add a property to the checkbox, to link it to the company, and simply scan each input which type="checkbox" with this attribute
HTML Code:
<div class="item clearfix">
    <div class="box1"> 
        <input type="checkbox" name="chkIds" id="chk26671398" value="26671398" companyName="Electronics"/>
    </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" companyName="Department" />
    </div>
    <div style="margin-bottom:5px;">
        <a href="http://company2.com" target="_blank" class="company">Department</a>
    </div>
</div>
Code:
aryChk=document.getElementsByTagName('input');
for(cpt=0;cpt<aryChk.length;cpt++){
    elm=aryChk[cpt]
    if(elm.type=='checkbox' && elm.getAttribute('companyName')!=null){
        //we have a checkbox input, with a company link
        if(elm.checked==false){
            alert('You have not checked the good company')
        }
    }
}
I tested it with this in firefox:
HTML Code:
<html>
<body>
<div class="item clearfix">
    <div class="box1"> 
        <input type="checkbox" name="chkIds" id="chk26671398" value="26671398" companyName="Electronics"/>
    </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" companyName="Department" />
    </div>
    <div style="margin-bottom:5px;">
        <a href="http://company2.com" target="_blank" class="company">Department</a>
    </div>
</div>
<input type="button" value="check" onclick="javascript:check()"/>
<script type="text/javascript">
function check(){
    aryChk=document.getElementsByTagName('input');
    for(cpt=0;cpt<aryChk.length;cpt++){
        elm=aryChk[cpt]
        if(elm.type=='checkbox' && elm.getAttribute('companyName')!=null && elm.getAttribute('companyName')=='Electronics'){
            //we have a checkbox input, with a company link
            if(elm.checked==false){
                alert('You have not checked the good company')
            }
        }
    }
}
</script>
</body>
</html>
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Reply     « Reply to how scan by userjs ?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.10588 seconds with 12 queries