Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Apr 2006
    Posts
    231
    Thanks
    9
    Thanked 1 Time in 1 Post

    onClick Change Value

    Hey all, I got a simple image button that when clicked, i want it to change the value of a hidden text input.
    So pretty much, a statement that changes the value of an input.

    something like getElementById.name.value=blabla??

    no idea, javascript rookie. I searched but couldn't find something like that.

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,922
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    Code:
    <input type = "hidden" name = "txt1" id = "txt1">
    
    <img src = "yourImage.gif" onclick = "change()">
    
    <script type = "text/javascript">
    function change() {
    document.getElementById("txt1").value = "blahblah"
    }
    </script>

  • Users who have thanked Philip M for this post:

    Erindesign (05-03-2008)

  • #3

  • #4
    Regular Coder
    Join Date
    Apr 2006
    Posts
    231
    Thanks
    9
    Thanked 1 Time in 1 Post
    is there a way to make an onclick link?

    like onclick here open a new page... say im at the main index.php now and on click i wnat to open page1.php... (same browser not popup).

  • #5
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,922
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    This is pretty basic! Surely you know how to do this?

    <a href = "http://www.yourdomain.com/secondpage.html"> LINK </a>


  •  

    Posting Permissions

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