Solved

Need Scroll Scale Bars to change values

Posted on 2003-12-04
5
295 Views
Last Modified: 2007-12-19
hi,

i need 2 scroll bars inside the site to change the value of some thing like height and width but they have to work in accordance with each other if one is 25 the other has to be 25 aswell or 98 - 98 . one has to be aligned vertical the other horizontal.

Its very easy to implement these in TCL / TK

have a look at these pics thats in TCL / TK and it would be nice if
they could look like those:

 http://www.apexmedia.de/ebay/scale.gif
 http://www.apexmedia.de/ebay/scale2.gif
0
Comment
Question by:Dopeman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 10

Accepted Solution

by:
NetGroove earned 125 total points
ID: 9878571
Check this for browser side only:

<html>
<head>
<script>
var sCount = 0;
var theForm;
function incSlidCount(theField){
theField.value=theField.value.replace(/\D/g,'');
newCount = theField.value * 1;
if(newCount>sCount){
  sArea = document.getElementById('sliderFarm');
  for(i=sCount;i<theField.value;i++){
      sArea.innerHTML += newSlider(i+1)
  }
  sCount = newCount;
}
}
function newSlider(sId){
sCode = '<table border=0>'
sCode += '<tr style="font-size:12"><td></td><td>&nbsp;&nbsp;</td>';
for(var i=1;i<10;i++){
  sCode+='<td><center>'+i+'</center></td>'
}
sCode += '<td>&nbsp;&nbsp;</td></tr>'
sCode += '<tr style="font-size:6"><td></td><td>&nbsp;&nbsp;</td>';
for(var i=1;i<10;i++){
  sCode+='<td><center>|</center></td>'
}
sCode += '<td>&nbsp;&nbsp;</td></tr>'
sCode += '<tr><td>Slider '+sId+'</td><td colspan="11">';
  sCode += '<span id="S'+sId+'" style="overflow-x:scroll; overflow-y:hidden; width:200; height=15;"';
sCode += ' onScroll="scrollSlider(this)">';
for(var i=0;i<600;i++){
  sCode+= "&nbsp;";
}
sCode+='</span></td><td>';
sCode+='<span id="LS'+sId+'">1</span></td></tr></table>';
sCode+='<input type=hidden name="VS'+sId+'" value="1">';
return sCode;
}

function scrollSlider(theSpan){
sId = theSpan.id;
sVal = Math.round(theSpan.scrollLeft/theSpan.scrollWidth*9)+1;
document.getElementById('L'+sId).innerHTML = sVal;
theForm["V"+sId].value = sVal;
}

function enter(e){
keyCode = (e.keyCode)?e.keyCode:e.which;
if(keyCode==13) {
  e.srcElement.onchange();
  return false;
}
}
function init(){
theForm = document.forms[0];
theForm.slidCount.select();
theForm.slidCount.focus();
}

function showSliderValues(theButton){
 msg = "";
 theForm = theButton.form;
 for(i=1;i<=sCount;i++){
   msg+= "\n\tslider"+i+"= "+theForm["VS"+i].value;
 }
 alert("Slider positions:"+msg)
}
</script>

</head>
<body onLoad="init()">
<form>
How many slider you need? Total:
<input type=text name="slidCount" size="1" value="0" onChange="incSlidCount(this)" onKeyPress="return enter(event)">
<div id="sliderFarm"></div>
<input type=button value="Show" onClick="showSliderValues(this)">
</form>
</body>
</html>


0
 
LVL 10

Expert Comment

by:NetGroove
ID: 9878577
And this for ASP server side control:

<%@ LANGUAGE = VBScript %>
<%  Option Explicit     %>
<%

Function newSlider(sId)
 Dim sCode
Dim i
sCode = "<table border=0>"
sCode = sCode & "<tr style='font-size:12'><td></td><td>&nbsp;&nbsp;</td>"
For i = 1 to 9
   sCode = sCode & "<td><center>" & i & "</center></td>"
Next
sCode = sCode & "<td>&nbsp;&nbsp;</td></tr>"
sCode = sCode & "<tr style='font-size:6'><td></td><td>&nbsp;&nbsp;</td>"
For i = 1 to 9
   sCode = sCode & "<td><center>|</center></td>"
Next
sCode = sCode & "<td>&nbsp;&nbsp;</td></tr>"
sCode = sCode & "<tr><td>Slider " & sId & "</td><td colspan='11'>"
 sCode = sCode & "<span id='S" & sId & "' style='overflow-x:scroll; overflow-y:hidden; width:200; height=15;'"
sCode = sCode & " onScroll='scrollSlider(this)'>"
For i = 1 to 600
  sCode = sCode & "&nbsp;"
Next
sCode = sCode & "</span></td><td>"
sCode = sCode & "<span id='LS" & sId & "'>1</span></td></tr></table>"
sCode = sCode & "<input type=hidden name='VS" & sId & "' value='1'>" & Chr(13)
Response.Write sCode
If (Request.form("VS" & sId) > "") Then  
%>
  <script>setSlider('S<%=sId%>', <%=Request.form("VS" & sId)%>)</script>
<%  
End If
End Function

%>

<html>
<head>
<title>Gauge</title>
<script>
function setSlider(sId, sVal){
 sObj = document.getElementById(sId);
 sObj.scrollLeft = sObj.scrollWidth/9*(sVal-1);
}

function scrollSlider(theSpan){
theForm = document.forms[0];
sId = theSpan.id;
sVal = Math.round(theSpan.scrollLeft/theSpan.scrollWidth*9)+1;
theForm["V"+sId].value = sVal;
document.getElementById('L'+sId).innerHTML = sVal;
}

function init(){
 theForm = document.forms[0];
}

</script>

</head>
<body>
<form name="myForm" METHOD="Post">

<% newSlider(1) %>

<% newSlider(2) %>

<% newSlider(3) %>

<br><br>
<input type=submit>

</form>
</body>
</html>

0
 

Author Comment

by:Dopeman
ID: 9880927
thanks for the quick answer,

i cant try the ASP one because i only have PHP support :( but the other one works fine exept for 4 things.

1. How can i syncronize them so that they work togehter on shows 20 the other one shows 2 aswell.

2. How can i make him show the result after i moved one of the scroll bars?

3. How can make a larger scale? like 100 or 1000

4 How can i make a vertical scale?

i tried to solve them myself but i dont know much about Javascript ;)

thanks,
Dope
0
 

Author Comment

by:Dopeman
ID: 9881190
!!!UPDATE!!!

Question number one is NOT important any more, but i need something like a preset value so i have a scale from 1 to 100
and the scale is preset on 50.

Is that possible???


0
 

Author Comment

by:Dopeman
ID: 9955336
Thanks NetGrove for your good and quick help
 but I found a slider solution which has more options i requiered here:

http://webfx.eae.net/dhtml/slider/slider.html

0

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question