Calling a function (from script) using checkbox
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello. I am creating a GUI that has a checkbox which when clicked would load a function from a separate script. Can anyone tell me how? Thank you.
1 Kommentar
Linda Cianciolo
am 14 Dez. 2014
Lets try this one
Step 1
/*********************************************** * Limit number of checked checkboxes script- by JavaScript Kit (www.javascriptkit.com) * This notice must stay intact for usage * Visit JavaScript Kit at http://www.javascriptkit.com/ for this script and 100s more *********************************************/
function checkboxlimit(checkgroup, limit){ var checkgroup=checkgroup var limit=limit for (var i=0; i<checkgroup.length; i++){ checkgroup[i].onclick=function(){ var checkedcount=0 for (var i=0; i<checkgroup.length; i++) checkedcount+=(checkgroup[i].checked)? 1 : 0 if (checkedcount>limit){ alert("You can only select a maximum of "+limit+" checkboxes") this.checked=false } } } }
Step 2
id="world" name="world" type="checkbox" name="countries" / USA<br /> type="checkbox" name="countries" / Canada<br /> type="checkbox" name="countries" / Japan<br /> type="checkbox" name="countries" / China<br /> type="checkbox" name="countries" / France<br /> /form
//Syntax: checkboxlimit(checkbox_reference, limit) checkboxlimit(document.forms.world.countries, 2)
Antworten (1)
Image Analyst
am 14 Dez. 2014
Here's a nice framework to get you going. http://www.mathworks.com/matlabcentral/fileexchange/24224-magic-matlab-generic-imaging-component
Otherwise you'll have to build the GUI yourself with a bunch of calls to uicontrol() along with all the tedious arguments you need to supply.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Entering Commands finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!