Passing form values with Array
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Soti_Soti
Posted On:   Thursday, November 21, 2002 03:58 PM

var arrayOfData1 = ["Buying","Refinancing","Other"]; var arrayOfData2 = ["Rates are too high", "I don't trust that my personal online", "I didn't want to be charged an application fee ", "I never enter my credit card information online", "I had too many questions about the application process "]; var arrayOfData3 = ["Accessed the Glossary sectionof the web site", "Called the 800# ", "Left the web site "]; rnd.today=new Date(); rnd.seed=rnd.today.getTime(); function rnd() { rnd.seed = (rnd.seed*9301+49297) % 233280; return rnd.seed/(233280.0); }; function rand(number) { return Math.floor(rnd()*number); }; function writeRadioButton(name, array) { while (array.length > 0) { var randOption = rand(array.length); document.write(' ' + array[randOption] + '    More>>


Hello-
I have to develop a script that will randomly rotate selections on a form (radio buttons), I have been able to accomplish this but I have just realized that I am not passing the value for each selection. I have pasted the script below, any help greatly appreciated:


			








onsubmit="return checkRequired(this)">



VALUE="http://www.thankyou"/>


VALUE=" Q01,Q02,Q03,Q04,Q05,Q06,Q07,Q08,Q09,Q10,Q11,Q12,Q1
3,Q14,Q15,Q16,Q17,Q18"/
>

Please tell us your interest in visiting our website:



If you did not complete & submit our online application, what was the top
reason that prevented you from doing so?




If you had a question while on our web site, what action did you take to
help get an answer to your question?






   <<Less

Re: Passing form values with Array

Posted By:   Nitesh_Naveen  
Posted On:   Friday, November 22, 2002 01:44 AM

I hope what you mean is that for each of these texts you have an id and you need to have that as the value in the radio button... You have to make some small changes in your code. for eg. you should build the array as...

var arrayOfData1 = new Array();
var myObj = new Object();
myObj.id = "1";
myObj.text = "Buying";
arrayOfData1[arrayOfData1.length] = myObj;
myObj = new Object();
myObj.id = "2";
myObj.text = "Refinancing";
arrayOfData1[arrayOfData1.length] = myObj;
myObj = new Object();
myObj.id = "3";
myObj.text = "Other";
arrayOfData1[arrayOfData1.length] = myObj;
...

And the function will now be...

function writeRadioButton(name, array) {
while (array.length > 0) {
var randOption = rand(array.length);
var tempObj = array[randOption];
document.write(' ' + tempObj.text + '');
array[randOption] = array[array.length - 1]
--array.length;
}
}
About | Sitemap | Contact