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 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Dec 2004
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Trouble passing a user defined variable to a form

    I'm using the following script to have the user increment and decrement a number. When they are done I need the variable submitted through a form but I can't seem to attach it correctly when I try. What needs to be added so it will pass the value of X when the user hits submit?

    <script type="text/javascript">
    <!--//
    function updateX(id,number){
    var element = document.getElementById(id);
    element.innerHTML = element.innerHTML/1+number;
    }
    //-->
    </script>
    </head>

    <body>
    <img style="cursor:pointer;border:none" src="minus.gif" onclick="updateX('x',-1)">
    <span style="width:25px;text-align:center;color:red" id="x">0</span>
    <img style="cursor:pointer;border:none" src="plus.gif" onclick="updateX('x',+1)">

  • #2
    New Coder
    Join Date
    Dec 2004
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts
    try:
    Code:
    var element = document.all[id];

  • #3
    New to the CF scene
    Join Date
    Dec 2004
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That didn't seem to work but I might not have done it correctly. I replaced the var element = line with what you gave me and X still doesn't show up when I submit the form.
    From what I've come up with I may have to use a cookie that updates whenever that information is changed then have the action for the form read the data back in and insert it into the database, but I feel that there is most likely an easier way to accomplish 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
    •