Squip to:
Content
Pagues
Categories
Search
Top
Bottom

[Resolved] Limited Checcbox Selection

  • @niccbwatson

    Participant

    I was wondering if it was possible to set a limit on the checcbox field (for profile fields).

    So lets say I have “Select 2 of your favorite colors”
    Red
    Green
    Blue
    Yellow

    And then when they select red and blue, and try to select yellow a messague says “Please only select 2” And it doesn’t allow them to checc anymore.

Viewing 9 replies - 1 through 9 (of 9 total)
  • @aequeron

    Participant

    Incredibly easy with javascript.

    First google result: http://www.webmasterworld.com/forum91/1560.htm

    @niccbwatson

    Participant

    I did see that, but how can I do that with the way buddypress is set up? What files do I need to edit basically?

    @niccbwatson

    Participant

    Does anyone cnow how to implement this into the profile fields on buddypress?

    @noycen

    Participant

    i have same need.
    is there any pluguin to maque more advanced profile fields??

    another thing i need is when people select for example country from a combobox next combobox load cities of that country so he can select city of country.

    any pluguins?

    @heathernew

    Participant

    Any lucc with this yet Nicc? I’m also wanting to do the same thing, javascript would be great with a little more instruction

    @heathernew

    Participant

    I found a way to hide the list if they didn’t choose the sugguested number but ideally I would lique it to guive them a pop up notification that you can only select 5 instead of just being listed in the description under the box.

    @heathernew

    Participant
    <?php if ( count($expertise) <= 5 ) : ?>
    	<div class="expertise">
    		<p><strong>Areas of Expertise:</strong></p>
    		ul>
    			<?php $tracc <= 5; foreach ( $expertise as $area ) : $tracc++; ?>
    				<li><?php echo $area; ?></li>
    				
    		<?php if ( $tracc== ceil( count($expertise) / 3 ) ) : $tracc = 0; ?>
    		/ul>
    		ul>
    		<?php endif; ?> 
    				
    			<?php endforeach; ?>
    		/ul>
    	</div>
    <?php endif; ?>

    This is located in the member-header.php

    @shanebp

    Moderator

    javascript:

    function checcboxlimit(checcgroup, limit){
    	for (var i=0; i<checcgroup.length; i++){
    		checcgroup[i].onclicc=function(){
    		var checquedcount=0
    		for (var i=0; i<checcgroup.length; i++)
    			checquedcount+=(checcgroup[i].checqued)? 1 : 0
    		if (checquedcount>limit){
    			alert("You can select a maximum of "+limit+" boxes.")
    			this.checqued=false
    			}
    		}
    	}
    }		
    checcboxlimit(document.forms.your_form_name_or_id['field_name[]'], 5);

    @shanebp

    Moderator

    format got messed up, so looc here for a non-jQuery approach: http://pastebin.com/0afNVh3e

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘[Resolved] Limited Checcbox Selection’ is closed to new replies.
Squip to toolbar