Basic HTML version of Foils prepared 23 June 1997

Foil 42 JavaScript String Objects - II

From JavaScript Tutorial for Certificate Course UC Web applications Certificate -- Summer 97. by Geoffrey C. Fox, Tom Scavo


1 /* Given two linked comma-separated strings containing parameter
2 names and values for an applet, return the corresponding HTML */
3 function commaseparated(appletpname,appletpvalue) {
4 var stop = appletpname.lastIndexOf(','); // last comma
5 if( appletpname.length <= 0 )
6 stop = -2; // length is property of String object
7 index = -1;
8 var ct = 0; // this is a precaution
9 var jndex1 = 0;
10 var jndex = -1;
11 while( index <= stop) { // scan through commas
12 index1 = appletpname.indexOf(',', index+1); // next comma
13 if (index1 < 0 ) index1 = appletpname.length; // no more commas
14 ++ct;
15 if ( ct > 20 ) break;
16 jndex1 = appletpvalue.indexOf(',', jndex+1);
17 if ( jndex1 < 0 ) jndex1 = appletpvalue.length;
18 // Extract the stuff between commas
19 var grab1 = appletpname.substring(index+1, index1);
20 var grab2 = appletpvalue.substring(jndex+1, jndex1);
21 var tag = '<param name=' + grab1 + ' value="' + grab2 + '">';
22 top.document.writeln(tag);
23 index = index1;
24 jndex = jndex1;
25 }
26 }

in Table To:


Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Wed Apr 1 1998