Avatar billede dwj Nybegynder
24. november 2000 - 11:49 Der er 1 løsning

Check box

Jeg har en form hvor man kan bestille nogen brochure.

Der er 6 check boxe og jeg vil gerne have at man kun kan få lov til at sætte kryds i 2 af check boxene.
Hvordan gør jeg det.
Avatar billede toni01 Nybegynder
24. november 2000 - 11:57 #1

Hej dwj

Sådan jeg har selv lige haft det samme problem (0:
her er en løsnings måde.

-toni01

<!-- TWO STEPS TO INSTALL LIMIT BOXES:

  1.  Copy the coding into the HEAD of your HTML document
  2.  Add the last code into the BODY of your HTML document  -->

<!-- STEP ONE: Paste this code into the HEAD of your HTML document  -->

<HEAD>

<SCRIPT LANGUAGE=\"JavaScript\">
<!-- Original:  Glenn Wang (brief@ix.netcom.com) -->
<!-- Web Site:  http://capsule.bayside.net/ -->

<!-- Modified by Ronnie T. Moore (The JavaScript Source) -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
function countChoices(obj) {
max = 3; // max. number allowed at a time

box1 = obj.form.box1.checked;  // your checkboxes here
box2 = obj.form.box2.checked;
box3 = obj.form.box3.checked;  // add more if necessary

count = (box1 ? 1 : 0) + (box2 ? 1 : 0) + (box3 ? 1 : 0);
// If you have more checkboxes on your form
// add more  (box_ ? 1 : 0)  \'s separated by \'+\'

if (count > max) {
alert(\"Oops!  You can only choose up to \" + max + \" choices! \\nUncheck an option if you want to pick another.\");
obj.checked = false;
  }
}
//  End -->
</script>
</HEAD>

<!-- STEP TWO: Copy this code into the BODY of your HTML document  -->

<BODY>

<center>
<form>
Please choose up to 2 sections:
<p>
<input type=checkbox name=box1 onClick=\"countChoices(this)\">Section 1
<p>
<input type=checkbox name=box2 onClick=\"countChoices(this)\">Section 2
<p>
<input type=checkbox name=box3 onClick=\"countChoices(this)\">Section 3
<p>
</form>
</center>

<p><center>
<font face=\"arial, helvetica\" size=\"-2\">Free JavaScripts provided<br>
by <a href=\"http://javascriptsource.com\">The JavaScript Source</a></font>
</center><p>

<!-- Script Size:  1.55 KB -->
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Vi tilbyder markedets bedste kurser inden for webudvikling

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester