SitePoint Sponsor

User Tag List

Results 1 to 10 of 10

Hybrid View

  1. #1
    SitePoint Enthusiast Slarti42's Avatar
    Join Date
    May 2001
    Location
    UK
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Validate a checkbox change??

    I have a form to edit a field in a database. I want to display a confirmation dialouge if one checkbox is changed from the default value. ie if it's ticked when the load the page and they untick it I want the confirmation box to come up.

    Thanks for any help

    Slarti

  2. #2
    ALT.NET - because we need it silver trophybronze trophy dhtmlgod's Avatar
    Join Date
    Jul 2001
    Location
    Scotland
    Posts
    4,836
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    slarti? Is that you?

    anyway, try this
    Code:
    <input type="checkbox" name="chngPass" value="True" onChange="javascript:alert('You changed the checkbox!!');'>
    Will work with it being checked, or unchecked.


  3. #3
    SitePoint Enthusiast Slarti42's Avatar
    Join Date
    May 2001
    Location
    UK
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    didn't seem to work

    Thanks for the sugestion but it didn't seem to work. I'm generating the page from PHP, would that make any difference??

    I display the checkbox like this:

    PHP Code:
    echo("<tr>\n".
    "<td align='right'>carotw &nbsp</td>\n".
    "<td align='left'><input type=checkbox name='carotw' $carotw></td>\n"); 
    where the $carotw is set to either "checked" or "".

    Any other ideas??

  4. #4
    ALT.NET - because we need it silver trophybronze trophy dhtmlgod's Avatar
    Join Date
    Jul 2001
    Location
    Scotland
    Posts
    4,836
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Whoops, typing mistake, and I know this works, I tested it my self:
    Code:
    <input type="checkbox" name="testing" value="testing" onChange="javascript:alert('You hanged it');">

  5. #5
    SitePoint Enthusiast Slarti42's Avatar
    Join Date
    May 2001
    Location
    UK
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Is it me??

    This line still dosen't seem to work???

    I'm using IE5.5 SP2 is that the problem??

    I tried just a simple form with just this checkbox on and still nothing. Do you need anything in the head or is this it??

    Sorry to keep on, and thanks

  6. #6
    ALT.NET - because we need it silver trophybronze trophy dhtmlgod's Avatar
    Join Date
    Jul 2001
    Location
    Scotland
    Posts
    4,836
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Check it, then click anywhere else on the page.

  7. #7
    SitePoint Enthusiast Slarti42's Avatar
    Join Date
    May 2001
    Location
    UK
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Still nothing!!

    I give up it still won't work for me!!!

  8. #8
    ALT.NET - because we need it silver trophybronze trophy dhtmlgod's Avatar
    Join Date
    Jul 2001
    Location
    Scotland
    Posts
    4,836
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Slarti, could you post the page online?

  9. #9
    SitePoint Enthusiast Slarti42's Avatar
    Join Date
    May 2001
    Location
    UK
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Sorted!!

    Thank you very much dhtlgod!!

    I finally saw that a simple space between java and script was stoping it working. I changed it to "javascript" and it worked.

    I've also looked at using "onClick" to bring up the alert.

    From here I should be able to change it to a confirmation dialouge without too much trouble.

    Thanks again for you help

    Slarti

  10. #10
    ALT.NET - because we need it silver trophybronze trophy dhtmlgod's Avatar
    Join Date
    Jul 2001
    Location
    Scotland
    Posts
    4,836
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No problem, thats what I'm here for


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
  •