Results 1 to 4 of 4

Thread: so simple...

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923

    so simple...

    I have a checkbox in a form. When the user ticks the box, I want a string to be entered into text box in the same form. If they untick the box, I want the value to be cleared in the text box

    Code:
    <script language="javascript">
    <!--
    
    function inserthttp() {
        if (document.add_product.Multipage.value = 1) {
            document.add_product.MultipageURL.value = "some value"
        } else {
            document.add_product.MultipageURL.value = ""
        }
    }
    
    //-->
    </script>
    
    .........
    
    <input type="checkbox" name="Multipage" value="1" onclick="javascript:inserthttp();">
    This will insert the "some value" when you click on the checkbox, but it won't clear the value when you click on it again.

    Any ideas?

  2. #2
    Fanatic Member Psyrus's Avatar
    Join Date
    Jul 2000
    Location
    NJ
    Posts
    602
    Change you code to this:

    function inserthttp() {

    if (document.add_product.Multipage.checked) {
    document.add_product.MultipageURL.value = "some value";
    }
    else {
    document.add_product.MultipageURL.value = "";
    }
    }
    Chris

    VB 6.0 Calendar App Video Gamers Group
    Don't forget to rate people if they helped you.

  3. #3
    Addicted Member
    Join Date
    Nov 2001
    Location
    Yewston, Texis
    Posts
    240
    I'm not exactly sure what's happening without doing a little experimentation. How I would solve the problem is to place an alert('value=' + document.add_product.MultipageURL.value);
    as the second line of the inserthttp() because it looks to be the case that MultiPage's value is not varying from 1. If this is the case, the alert will help you figure out what you need to do to MultiPage to make it's value vary according to your needs.

    cudabean

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    thanks, got it

Posting Permissions

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



Click Here to Expand Forum to Full Width