Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing in variables to JavaScript.

Status
Not open for further replies.

Nunners

Programmer
Aug 22, 2001
25
GB
All,

I have a piece of code which enables some scrolling text along the screen. This code was 'borrowed' from another source. However my JavaScript knowledge is limited and i cannot get this code to do what i require. This is where someone steps in with some help....The code is.....

<form id=&quot;hiddenOracleForm&quot;>
<input type=&quot;hidden&quot; name=&quot;recordset1&quot; value=&quot;banana, grape, orange&quot;>
<input type=&quot;hidden&quot; name=&quot;recordset2&quot; value=&quot;<oracle>select fruit from basket</oracle>&quot;>
</form>

<!-- START OF SCRIPT -->
<HTML>
<HEAD>
<TITLE>4 Line Scroller</TITLE>
</HEAD>
<BODY BGCOLOR=&quot;FFFFFF&quot; TEXT=&quot;000000&quot; LINK=&quot;0000FF&quot; VLINK=&quot;800080&quot; ALINK=&quot;FF0000&quot;>
<head>
<script language=&quot;JavaScript&quot;>
<!-- begin
var max=0;
function textlist()
{
max=textlist.arguments.length;
for (i=0; i<max; i++)
this=textlist.arguments;
document.write('the variable for rs1 is ' + rs1);
}
var rs1 = document.forms['hiddenOracleForm'].recordset1.value;
tl=new textlist
(
rs1
);
var x=0; pos=0;
var l=tl[0].length;
function textticker()
{
document.tickform.tickfield.value=tl[x].substring(0,pos)+&quot;_&quot;;
if(pos++==l) { pos=0; setTimeout(&quot;textticker()&quot;,1000); x++;
if(x==max) x=0; l=tl[x].length; } else
setTimeout(&quot;textticker()&quot;,50);
}
// end -->
</script>
<head>
<body onLoad=&quot;textticker()&quot; >
<center>
<form name=&quot;tickform&quot;><input type=text name=&quot;tickfield&quot; size=40></form>
</BODY>
</HTML>

We can see from the above code that the variable RS1 gets set in the javascript like so....var rs1 = document.forms['hiddenOracleForm'].recordset1.value;

And the form elements are set in the HTML.

My problem is, if i included recordset2.value, just the same a rs1, the code errors. Is there something i am not understanding about how javascript works. Can i not set more than one varible within JavaScript?

Another problem i am unable to sort out.....it is highly likely that i won't know how many variables i am going to be setting to text in the JavaScript, this can be a random number of variables, ranging from rs1 to rs10, for example..

Also, if i try to add rs2 with rs1 in the textlist, i also get an error.

Any help would be greatly appreciated.

Nunners
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top