Results 1 to 3 of 3

Thread: help

  1. #1
    zia Guest

    Default help

    I am displaying checkboxes on the fly ie they are<BR>being generated dynamically depending on the user<BR>logged in.Some users will have 4 checkboxes & some <BR>may have 8 displayed on their page & so on.<BR>Now this is working good.<BR>But the problem is that it is compulsory for every<BR>user to atleast check 1 checkbox or else a javascript<BR>error should pop up like an alert box when user submits the<BR>form without checking any of the checkboxes.<BR>How do I do this especially when the checkbox is<BR>coming dynamically.<BR>I have used the following to display the checkboxes<BR>dynamically by giving the line below in a for loop<BR>&#060;input type=checkbox name=type&#060;%=i%&#062;&#062;<BR>where the variable &#039;i&#039; will keep incrementing from 1 till number of checkboxes to be shown.As I said it is working but the<BR>only problem is that I am not able to display the error<BR>when no checkbox is checked.<BR>Any Idea.

  2. #2
    Join Date
    Dec 1969

    Default RE: help

    Hello,<BR><BR>You can easily do this work by using a function to check b4 your submits <BR>&#060;form onsubmit = "return check()" name="form_name" ...etc &#062; <BR><BR>after this place this --&#062;&#062;<BR><BR>&#060;script Language="JavaScript"&#062;<BR>function check()<BR>{correct = true <BR><BR>if (document.form_name.check_box1.value=1 OR document.form_name.check_box2.value=1 OR document.form_name.check_box3.value=1 OR )<BR> {correct=false ; alert ("Check mark atleast one of them ")<BR> return correct <BR> }<BR>&#060;/script&#062;<BR><BR>and you will do ur work..

  3. #3
    zia Guest

    Default RE: help

    Thanks a lot for the reply & help<BR>but since the checboxes are coming dynamically I <BR>can&#039;t give the condition below as you said<BR>if (document.form_name.check_box1.value=1 OR document.form_name.check_box2.value=1 OR document.form_name.check_box3.value=1 OR ) <BR>I mean I can&#039;t hardcode the name of checkboxes as different users will have diff no. of checkboxes.<BR>how do I handle this

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts