Current location: Hot Scripts Forums » General Web Coding » JavaScript » spinner control and using number to activate href to bookmark


spinner control and using number to activate href to bookmark

Reply
  #1 (permalink)  
Old 08-18-10, 08:23 PM
markcorrigan markcorrigan is offline
New Member
 
Join Date: Aug 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
spinner control and using number to activate href to bookmark

Hi All. I desperately need help with Javascript.
Problem. I have quite an advanced spinner program. It was obtained here: Javascript Controls - The Spin Control | Switch on the Code

I am trying to get a spinner button (which selects from 6 - 30 [but customizable] numbers to update a variable and then for this variable to update a href link to a bookmark.

What I have so far.

1. SPINNER CODE on web page. NB the javascript code this refers to is not shown
HTML Code:
</head>
<body>
<script type="text/javascript">
var spinCtrl = new SpinControl();
spinCtrl.GetAccelerationCollection().Add(new SpinControlAcceleration(1, 300));
document.body.appendChild(spinCtrl.GetContainer());
spinCtrl.StartListening();
spinCtrl.Tag = 'left';
spinCtrl.SetMaxValue(30);
spinCtrl.SetMinValue(6);
spinCtrl.GetContainer().style.position = 'absolute';
spinCtrl.GetContainer().style.left = '15px';
spinCtrl.GetContainer().style.top = '10px';
spinCtrl.AttachValueChangedListener(spinCtrlPrintOut);
spinCtrl.AttachValueChangedListener(spinCtrlSizeBox);
spinCtrl.AttachValueChangedListener(spinner);  --->I added this
spinCtrl.SetCurrentValue(6);
</script>
The HREF link:
HTML Code:
<a href="example.html" id ="name" onclick="location.href=this.href+'#'+link;return false;">Link</a>
going to a bookmark here: <a name="8">

AND my spinner function: PLEEZE note that ths is where the wheels come off.
I want the newVal variable in the functon [which containts the current spin number] to be put into a variable and then for the variable to be sent outside the function to "link" in HREF above. i.e. this way the HREF code can place in the #8and it will jump to the bookmark.
HTML Code:
 <script type="text/javascript">
function spinner(sender, newVal)
{
var hold = newVal;
var id = 'name' 
window.link = hold;
}
</script>

NOTE that a variable var link = 8; declared outside the function (globally) works perfectly.
But I simply cannot see how to get access to the newVar variable i.e. current spinner position within this function :
Code:
 function spinner(sender, newVal)
{
var hold = newVal;
var id = 'name' 
window.link = hold;
}
Anyone who knows how to do this will be blessed in my eyes. PS I am also a beginner programmer so may simply be missing a simple boat.

Kind regards

Mark (markjc@mweb.co.za)

Last edited by UnrealEd; 08-19-10 at 07:49 AM. Reason: fixed [html] and [code] tags
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 08-19-10, 09:13 AM
markcorrigan markcorrigan is offline
New Member
 
Join Date: Aug 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Hi this is solved.

I was up all night and sorted it out.

It seems to be working..... well I will still need to bug test a bit.

My output is here: Cost of Next Lessons
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks

Tags
spinner control, variables


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump


All times are GMT -5. The time now is 10:49 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.