SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: New to ASP...

  1. #1
    SitePoint Member
    Join Date
    Jun 2005
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    New to ASP...

    Hi, I got a problem with checkbox... how can I use ASP to mark & unmark the checkbox? For example, when I fulfill some condition, I need to mark some checkbox in page. Can it be done? Thanks in advance.

  2. #2
    SitePoint Evangelist luxinterior's Avatar
    Join Date
    Aug 2004
    Location
    Here, there and everywhere!
    Posts
    458
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well since a checkbox status is a matter of having the word CHECKED in the tag just put it in a variable on the page. Like:

    <input type="checkbox" name="chkFred" value="something" <%=strChecked%>>

    Where the variable strChecked is either empty ('') or CHECKED.

    Lux

  3. #3
    SitePoint Member
    Join Date
    Jun 2005
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    However, I'm creating the checkbox dynamically, from the server side using response.write "<INPUT type=checkbox>". That's why I find it difficult to attach the client side script to it. Anyway to get around this? Thanks again in advance.

  4. #4
    doing my best to help c2uk's Avatar
    Join Date
    May 2005
    Location
    Cardiff
    Posts
    1,832
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Where do you see a client side script? luxinterior used the short method to place a value of an variable into the html code.

    In your case, it should look like this:

    Code:
    Response.Write "<input type='checkbox' name='chkFred' value='something' " & strChecked & ">"
    Before this you could give strChecked the value "checked" with an if structure, something along those lines:

    Code:
    If x = True Then strChecked = "checked"
    Keep in mind, I'm an asp Beginner myself, and if something wrong about my code, I would welcome to get some insight, or if there are better solutions, I would welcome to hear of them.


Bookmarks

Posting Permissions

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