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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

getting upredictable results with the script

Status
Not open for further replies.

tester321

Programmer
Mar 13, 2007
150
CA
Hi i', getting upredictable results with the script below, it seems that for 40% of users, the script does not function. I tried it in Firefox, and IE 6+7, and all is well. Since i cant find an issue, i'm not sure how to solve it? I was wondering for someone can look over the JS to see if any thing stands out. The script creates a matrix of radio buttons based on a previous form page's selections of brands, the previously selected brands are set to the arrI array. Although this is dynamic i have hard coded values for ease of explaination. Thank you very much.

Code:
<script>

var a1='1';
var a2='ws92399';
var a3='1';
var a4='ws97876';
var a5='ws96699';
var a6='1';
var a7='ws99944';
var a8='1';

// previous brand selections in question 2 are set to arrI array
var arrI = new Array()
arrI[0]=a1
arrI[1]=a2
arrI[2]=a3
arrI[3]=a4
arrI[4]=a5
arrI[5]=a6
arrI[6]=a7
arrI[7]=a8
</script>


<h5>Question 6: Select satisfied level.  7 means very satisfied; 1 means very unsatisfied.</h5>

<style type="text/css">
.style1 {color: #000000;font-weight: bold;}
.style4 {color: #999999; }
.style6 {font-size: 10pt;font-family: Verdana, Arial, Helvetica, sans-serif;}
</style>

<script type="text/javascript">
var n = new Array()
n[0]='brand1'
n[1]='brand2'
n[2]='brand3'
n[3]='brand4'
n[4]='brand5'
n[5]='brand6'
n[6]='brand7'
n[7]='brand8'

var c = new Array()
c[0]='CCCCCC'
c[1]='CCCCCC'
c[2]='CCCCCC'
c[3]='CCCCCC'
c[4]='CCCCCC'
c[5]='CCCCCC'
c[6]='CCCCCC'
c[7]='CCCCCC'

document.write('<table width="500" border="0"><tr><td></td>');
document.write('<td bgcolor="#CCCCCC" align="center"><span class="style6">1<br />Very Unsatisfied</span></td>');


for (var x=2; x<7; x++) {
document.write('<td bgcolor="#'+c[x]+'" align="center"><span class="style6">'+x+'</span></td>');
}

document.write('<td bgcolor="#CCCCCC" align="center"> <span class="style6"> 7<br />Very Satisfied</span></td>');
document.write('</tr>');

for (var i=0; i<8; i++) {
 if (arrI[i].length==1) {
document.write('<tr><td bgcolor="#'+c[i]+'"><span class="style6">'+n[i]+'</span></td><td bgcolor="#'+c[i]+'" align="center"><input name="wsb28_'+i+'" type="radio" value="1" /></td><td bgcolor="#'+c[i]+'">');

document.write('<input name="wsb28_'+i+'" type="radio" value="2" /></td><td bgcolor="#'+c[i]+'" align="center"><input name="wsb28_'+i+'" type="radio" value="3" /></td>');

document.write('<td bgcolor="#'+c[i]+'" align="center"><input name="wsb28_'+i+'" type="radio" value="4" /></td><td bgcolor="#'+c[i]+'" align="center"><input name="wsb28_'+i+'" type="radio" value="5" /></td>');

document.write('<td bgcolor="#'+c[i]+'" align="center"><input name="wsb28_'+i+'" type="radio" value="6" /></td><td bgcolor="#'+c[i]+'" align="center"><input name="wsb28_'+i+'" type="radio" value="7" /></td></center></tr>');

  };

}

document.write('</table>');
</script>

<br />
 
Do 40% of your users have javascript disabled?

I'll point a thing or 2:

The close of your if (arrI.length == 1) { block is this: };. You need to take that ; out of there.

I see a closing </center> tag. That </center> does not have a starting tag, and is in an incorrect place anyway (after a TD).

<center> and align="center" are deprecated in place of the CSS style="text-align:center".

Your top <script> tag does not have a type associated with it.

Do these things and it may clear up your problems, may not though. [tiger]


[monkey][snake] <.
 
Thanks monksnake for your wisdon, i'll try those things, and yes the 40 % do have JS enabled, because i see the results to other form questions which are dynamic JS.

Thanks Again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top