Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-09-2004, 08:57 PM   PM User | #1
proj2501
New to the CF scene

 
Join Date: Dec 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
proj2501 is an unknown quantity at this point
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)">
proj2501 is offline   Reply With Quote
Old 12-09-2004, 09:09 PM   PM User | #2
aifilaw
New Coder

 
Join Date: Dec 2004
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
aifilaw is an unknown quantity at this point
try:
Code:
var element = document.all[id];
aifilaw is offline   Reply With Quote
Old 12-09-2004, 10:54 PM   PM User | #3
proj2501
New to the CF scene

 
Join Date: Dec 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
proj2501 is an unknown quantity at this point
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.
proj2501 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:43 AM.


Advertisement
Log in to turn off these ads.