...

View Full Version : Please help! to make a program with javascript



Michelle.G
05-17-2012, 03:04 PM
Hi! frnds, I was wondering if you could help me with the JavaScript programing...

Every possible help will be appreciated :)

I am very new to the world of programming and JavaScript but I have some Ideas which I would like to execute and I will learn anything and everything in the way to accomplish them...

Program:

user end: the page is about users priorities and displaying back the selected... the program work as a user reaction based comparison module...
where the priorities stored in the program are shown 2 at a time and lets user to select what is more important to him and stores the result in another variable than that variable is shown with another variable which is already stored and the result out of that is stored in another new variable and so on.. in the end it show the result of important selected priorities...

1) say there are 6 variables storing string values:


<script type = "text/javascript">
var p1 = "Doctors appointment";
var p2 = "studying for the exam";
var p3 = "Going out for most awaited shopping";
var p4 = "Login on Facebook";
var p5 = "Replying to text msgs";
var p6 = "Go out with friends";


2) there are two sections on the html document:

i) where the variables are displayed dynamically and changes the value on click..
it works like a comparison where user selects (onclick) what is more important to him shows the next value and so on...
in the end stores the result...

functioning(I have no I idea how to do this): say on the html document only two variables are displayed at first and than the user selects one of it as more important to him so the result is stored in another new variable than that new variable is shown with the third stored variable and once one of them is selected it is stored in another new variable and is compared with forth stored variable and so on till the last selected is stored as the result1...

all comparisons must happen on the same div of the html document procedure has to loop three times till 3 results (result1, result2, result3) out of six are selected more important...
result1 has to be removed from the next loop for result 2 as result1 is already selected important by the user..
result1 and result2 are to be removed from the next loop for result 3 as they are already selected important by the user

ii) the second section displays important 3 results (result1, result2, result3) selected by him...


my friend told jQuery can do the dynamic comparison part but I don't know how to use it...

the logic of creating new variable for storing result and then comparing can be improved or changed...

Please help :)

Michelle.G
05-17-2012, 03:19 PM
This sounds like a homework assignment.

Post the code you have so far and you are much more likely to get meaningful help.

Also, since you say you are very new, I would suggest you stay away from jQuery for now. After all, jQuery is just a library of normal JavaScript functions. It is not a different language to JavaScript. Therefore, you can't do anything with jQuery that cannot be done with JavaScript.

I am sorry to say but I am out of ideas of creating the user reaction based comparison function part in the program and that is why I am asking help...
I cant think how to write that comparison function :(

anyways thanks for your reply :)

Peeyush
05-17-2012, 03:29 PM
so do you know any javascript? i mean even a little? have you tried creating something? if you have please post it here. you cant make a program without knowledge of the programming language, copying and pasting scripts from here and there wont help....

Michelle.G
05-17-2012, 03:41 PM
so do you know any javascript? i mean even a little? have you tried creating something? if you have please post it here. you cant make a program without knowledge of the programming language, copying and pasting scripts from here and there wont help....

yes I know basics of programing in JavaScript :) eg: syntax, variable, arrays, data types,operators, built-in objects, DOM, conditions, loops etc...but the program I am trying to create is beyond my logic :( and that is why I am seeking help in here...

help is always appreciated :)

Philip M
05-17-2012, 04:31 PM
This seems a strange way to go about selecting the first three preferences out of six (if I have understood the assignment correctly). I would suggest using a select list:-


<html>
<head>
</head>
<body>

<form name='myform'>
<select name = 'list1' id = 'list1' onchange = "showOptions(this)">
<option selected value=""> Choose A Fruit</option>
<option value='Mango'> Mango </option>
<option value='Apple'> Apple </option>
<option value='Orange'> Orange </option>
<option value='Watermelon'> Watermelon </option>
<option value='Plum'> Plum </option>
<option value='Papaya'> Papaya </option>
</select>
<br><br><br>

First Preference:&nbsp &nbsp &nbsp <input type = "text" name = "txt1" id = "txt1" readonly"><br>
Second Preference: <input type = "text" name = "txt2" id = "txt2" readonly"><br>
Third Preference: &nbsp &nbsp <input type = "text" name = "txt3" id="txt3" readonly"><br>
<br><br>
<input type = "button" name = "but1" value = "Clear Preferences" onclick = "clearPrefs()">

</form>

<script type = "text/javascript">
var chosen = [];
for (var i = 0; i<document.myform.list1.length; i++) {
chosen[i] = 0;
}
var count = 1;

function showOptions(which){
var x = which.value;
var se = which.selectedIndex;
if (chosen[se] == 1) {
alert ("You have alreay chosen that option! Try again!")
return false;
}
if ((x!="") && (count <=3)){
chosen[se] = 1;
document.getElementById("txt"+count).value = x;
count ++;
}
}

function clearPrefs() {
count = 1;
document.myform.list1.selectedIndex = 0;
for (var i=1; i <=3; i++) {
document.getElementById("txt"+i).value = "";
}
for (var i = 0; i<document.myform.list1.length; i++) {
chosen[i] = 0;
}
}

</script>
</body>
</hrml>


There are of course many possible approaches. Someone else may think of a better one.

xelawho
05-17-2012, 05:14 PM
here's another way, just for kicks...



<!doctype html>
<html>
<head>

</head>

<body onload="display()">
<div id="questions">
Please note your preference: <br>
<input type='radio' name='rad' onclick='choose(1)'/><span id="opt1"></span>
<input type='radio' name='rad' onclick='choose(0)'/><span id="opt2"></span>
</div>
<div id="results"></div>

<script type="text/javascript">
var opts=[["Doctors appointment", "studying for the exam"], ["Going out for most awaited shopping", "Login on Facebook"], ["Replying to text msgs", "Go out with friends"]]

var choices=0;

function choose(idx) {
opts[choices].splice(idx,1);
if (choices==2){
document.getElementById("questions").style.display="none"
document.getElementById("results").innerHTML="Your preferences are:<br>"
for (var i = 0; i < opts.length; i++) {
document.getElementById("results").innerHTML+=opts[i][0]+"<br>"
}
} else{
choices++
display();
}
}

function display(){
document.getElementById("opt1").innerHTML=opts[choices][0]
document.getElementById("opt2").innerHTML=opts[choices][1]
}


</script>
</body>
</html>

Philip M
05-17-2012, 07:41 PM
The problem there is that the user may prefer "Doctor's appointment" to "Studying for exam", but what if he prefers "Studying for exam" to "Login on Facebook", "Replying to text msgs" or "Go out with friends"?

Or have I misunderstood the assignment?

c1lonewolf
05-17-2012, 09:25 PM
If I'm following this correctly, wouldn't it just be easier to create a form with all the options using a checkbox. Then use the box's onchange event handler to adjust an array accordingly.
"Select items according to importance"
Then if you needed to start over you simply uncheck everything.

Just wondering...

felgall
05-17-2012, 09:58 PM
If it were going to be used in the real world you'd need a way for it to work without JavaScript as well si the obvious starting point would be to simply create all the options as submit buttons and one extra to restart. You'd also have hidden fields to store the value(s) previously selected. The (theoretical) server side code would store the value from the selected submit button in the next unused hidden field when it redisplays the form with that button disabled until all are filled after which it would then proceed to process them all.

The JavaScript would then be attached to this si that it provides equivalent functionality by storing the value of the submit button in the next empty hidden field, disabling that submit button and then aborting the submit. It would do whatever is necessary as additional processing after the last hidden field is filled inb order to process all the hidden fields.

By using that design for the JavaScript you'd have a version that could be made to function without JavaScript by adding server side processing without having to make any changes to the form in order to implement it.

Michelle.G
05-17-2012, 10:18 PM
Hey sorry for the late reply had logged off by the time you all replied...

Thank you all for your efforts and contribution especially xelawho and Philip M...

I feel I was not efficient to explain the module correctly the closest was xelawho...

let explain with an example:

say there are 6 variables storing string values:

var p1 = "Doctors appointment";
var p2 = "studying for the exam";
var p3 = "Going out for most awaited shopping";
var p4 = "Login on Facebook";
var p5 = "Replying to text msgs";
var p6 = "Going out with friends";

how it works on the users end:
(this is what user sees on the page)

What is more important to you? if you had to do these thing at the same time, which one would you give the priority?
Options (click any one)

1) Doctors appointment // "Login on Facebook" // "Replying to text msgs" // "Going out with friends"

or

2) studying for the exam // "Going out for most awaited shopping"


//First click (select): if the user click on option 1 then option 1 remains there and option 2 changes to var p3 ("Going out for most awaited shopping")

//Second click (select): if the user then selects the option 2 where the value is var p3 "Going out for most awaited shopping" it remains unchanged there and the option 1 having value p1 ("Doctors appointment") changes to p4 ("Login on Facebook")

//Third click (select): if the user then selects again option 2 where its value is still var p3 then option 1 changes from var p4 ("Login on Facebook") to var p5 ("Replying to text msgs")

//Fourth click (select): if the user still selects option 2 where its value is still var p3 then option 1 again changes from var p5 to var p6 ("Go out with friends")

//Fifth click (select): if the user selects option 1 where its value is var p6 ("Going out with friends") over option 2 var p3 ("Going out for most awaited shopping")...
Then the result is stored as result1 and is displayed on the screen and the next loop starts for result2 where result1 (in example:"Going out with friends") has to be removed from the next loop for result 2 as result1 is already selected important by the user..
result1 and result2 are to be removed from the next loop for result 3 as they are already selected important by the user...

Yes! it is wierd type of selection and is complex but that is how it has to be :(

I hope I was efficient in explaining the module correctly this time :)

awaiting your reply :)

Old Pedant
05-17-2012, 11:00 PM
I think what is confusing is that you keep showing things like this:


1) Doctors appointment // "Login on Facebook" // "Replying to text msgs" // "Going out with friends"
or
2) studying for the exam // "Going out for most awaited shopping"

But *I THINK* what you mean is that what is DISPLAYED is only


1) Doctors appointment
or
2) studying for the exam

And you were just using the // stuff to show the parts that are HIDDEN to the user.

********

Am I right?

Michelle.G
05-17-2012, 11:16 PM
I think what is confusing is that you keep showing things like this:

But *I THINK* what you mean is that what is DISPLAYED is only

And you were just using the // stuff to show the parts that are HIDDEN to the user.

********

Am I right?

yes true!! // means hidden... but the hidden part corresponds to the explanation given below...

Please see the explanation below to understand the functioning :)

Old Pedant
05-18-2012, 12:07 AM
Okay, so the basic idea is simple. BUT... But what happens when you run out of one set of choices?


1) Doctors appointment // "Login on Facebook" // "Replying to text msgs" // "Going out with friends"
2) studying for the exam // "Going out for most awaited shopping"

Suppose the user choose option 1 twice.


Start:
1) Doctors appointment
2) studying for the exam

Choose option 1:
1) Doctors appointment
2) Going out for most awaited shopping

Choose option 1:
1) Doctors appointment
2)


So then, at this point, you show "Doctors appointment" in the output area and start over with


1) "Login on Facebook" // "Replying to text msgs" // "Going out with friends"
2) studying for the exam // "Going out for most awaited shopping"

Is that right?

So you do that until what?

And what happens if the FIRST TWO end results are

studying for the exam
Going out for most awaited shopping

Now there are no choices left in the second list.

Is the game over?

*********

You simply have *NOT* explained thoroughly enough and/or considered/explained all possible scenarios.

xelawho
05-18-2012, 12:15 AM
going for a wild swing here...

in that scenario, Doctors appointment gets saved as favorite 1 and the cycle of questions starts again, but with Doctor's appointment removed from the list

and so on until you have 3 faves?

Old Pedant
05-18-2012, 12:37 AM
Let me make that real problem scenario clearer:

These are the two sets of choices:


1) Doctors appointment // "Login on Facebook" // "Replying to text msgs" // "Going out with friends"
2) studying for the exam // "Going out for most awaited shopping"

So we start with:


1) Doctors appointment
2) studying for the exam

The user chooses option (2)

Which then gives us


1) Login on Facebook
2) studying for the exam

The user choose option 2 twice more and we have


1)
2) studying for the exam

So we put "studying for the exam" into the favorites list and now we start over with


1) Doctors appointment
2) Going out for most awaited shopping

Again, the user choose option 2 four times in a row and you end up with


1)
2) Going out for most awaited shopping

So you put "Going out for most awaited shopping" on the favorites list and you start again with


1) Doctors appointment
2)


OOPS! We ran out of items in the option (2) list!

But the user REALLY wants to choose "Replying to text msgs" as his/her third favorite.

BUT THERE IS NO WAY TO DO SO!

**********

The whole thing seems BADLY BROKEN to me. Unless the two sets of options *EACH* have AT LEAST THREE choices, there is no way to end up with three favorites each and every time.

**********

And by the way: Is this assignment REALLY being given in OHIO?

I am skeptical. I can't imagine any American teen-ager using the phrase "Going out for most awaited shopping". That sounds like a literal translation of Chinese or some other language.

Michelle.G
05-18-2012, 01:18 AM
Thank you! for your replies but I think I need to show some more examples for clarity of the module:

Example 2:

*say there are 6 variables storing string values:

var p1 = "Doctors appointment";
var p2 = "studying for the exam";
var p3 = "Going out for most awaited shopping";
var p4 = "Login on Facebook";
var p5 = "Replying to text msgs";
var p6 = "Going out with friends";



how it works on the users end:
(this is what user sees on the page)



What is more important to you? if you had to do these thing at the same time, which one would you give the priority?

Options (click any one)

Option 1) Doctors appointment // "Going out for most awaited shopping" //"Login on Facebook"

or

Option 2) studying for the exam // "Replying to text msgs" // "Going out with friends"


Please try to understand the explanation below to understand above example :)


//First click (select): if the user click on option 2 then option 2 having value p2 ("studying for the exam") remains unchanged and option 1 changes from var p1 ("Doctors appointment") to var p3 ("Going out for most awaited shopping")

//Second click (select): if the user still selects the option 2 where the value is var p2 ("studying for the exam") it remains unchanged and the option 1 having value p3 ("Going out for most awaited shopping") changes to p4 ("Login on Facebook")

//Third click (select): if the user then selects option 1 now where its value is var p4 ("Login on Facebook") then option 2 changes from var p2 ("studying for the exam") to var p5 ("Replying to text msgs")

//Fourth click (select): if the user selects option 2 where its value is var p5 ("Replying to text msgs") then option 1 changes from var p4 ("Login on Facebook") to var p6 ("Go out with friends")

//Fifth click (select): if the user selects option 1 where its value is var p6 ("Going out with friends") over option 2 var p3 var p5 ("Replying to text msgs")...

Then the result is stored as result1 and is displayed on the screen and the next loop starts for result2 where result1 (in example:"Going out with friends") has to be removed from the next loop for result 2 as result1 is already selected important by the user..

result1 and result2 are to be removed from the next loop for result 3 as they are already selected important by the user...


Just to understand (where it totally depends on user what he selects first) :

Option 1:
"Doctors appointment"
//"Going out for most awaited shopping"
//"Login on Facebook"
//"Replying to text msgs"
//"Going out with friends"

Or

Option 2:
"studying for the exam"
//"Going out for most awaited shopping"
//"Login on Facebook"
//"Replying to text msgs"
//"Going out with friends"



I hope you understand this time :)

Michelle.G
05-18-2012, 01:45 AM
It's a bit confusing for me as to what you actually want, but as a starting point I think for loop 1 you want 2 options to be displayed at a time.

When the user clicks their first preference between the the 1st 2 options, the preference and the next option is displayed (still displaying 2 options at a time). The user then clicks their preference between their first preference and the next option.

So at the end of the first loop, the user will have selected their favorite option from the 6 options. But then I have no idea what you want to happen in the next 2 loops since you say there are 3 loops.

Anyway, hopefully this example based on my understanding above will help you get started.

In this example, at the end of the loop the user's favourite out of the 6 options is displayed.


<body>
<div id="choicesContainer">
<p id="choice1Cont"></p>
<p id="choice2Cont"></p>
</div>
<p id="pFaveCont">Your favorite after loop 1 is: <span id="spFaveCont"></span></p>

<script type="text/javascript">
var choices = [
['0','Doctors appointment'],
['1','studying for the exam'],
['2','Going out for most awaited shopping'],
['3','Login on Facebook'],
['4','Replying to text msgs'],
['5','Go out with friends']
];
var result1 = '';
var currChoiceOpt = 0;
var choiceContObj = document.getElementById('choicesContainer').getElementsByTagName('p');
for(i=0; i<choiceContObj.length; i++){
choiceContObj[i].onclick = function(){getUserChoice(this);}
}
function displayOptions(){
if(currChoiceOpt == choices.length){
showFavourite();
return;
}
choice1ContObj = document.getElementById('choice1Cont');
choice2ContObj = document.getElementById('choice2Cont');
if(result1 == ''){
choice1ContObj.innerHTML = choices[currChoiceOpt][1];
choice1ContObj.idx = choices[currChoiceOpt++][0];
choice2ContObj.innerHTML = choices[currChoiceOpt][1];
choice2ContObj.idx = choices[currChoiceOpt++][0];
}else{
choice1ContObj.innerHTML = choices[result1][1];
choice1ContObj.idx = result1;
choice2ContObj.innerHTML = choices[currChoiceOpt][1];
choice2ContObj.idx = choices[currChoiceOpt++][0];
}
}
function getUserChoice(elem){
result1 = elem.idx;
displayOptions();
}
function showFavourite(){
document.getElementById('spFaveCont').innerHTML = choices[result1][1];
}
displayOptions();
</script>
</body>


Awesome you cracked it :thumbsup:

about the loop it has to show three results

Result1 = is selected (example: Going out for most awaited shopping)
then result1 value i.e (example: Going out for most awaited shopping) is to be removed from the list for second result..

comparing starts again

Result2 = is selected (example: 'Login on Facebook')
then the result 1 value and result 2 value are to be removed from the variable list to get result 3...

comparing starts again

Result3= is selected

Display

END


Thanksss a lottt for the help iBall :):thumbsup::)

and yes I will try to write the code as you said but truly speaking I am new and just 15 year old girl with lots of Ideas to accomplish... anyways I am working as much as possible...

Your help is more than appreciated iBall:)

Old Pedant
05-18-2012, 03:26 AM
Oh for crying out loud!

This is COMPLETELY DIFFERENT than what you showed before!


Option 1) Doctors appointment // "Going out for most awaited shopping" //"Login on Facebook"

Option 2) studying for the exam // "Replying to text msgs" // "Going out with friends"

NOW it makes sense. NOW you have THREE choices in each set of options.

Before you had it divided 4 and 2, and as I pointed out with 4 and 2 you can run out of choices in the 2 side!

Sheesh.

But okay, now that it makes sense, it's really easy. And can be done in a lot less code than iBall showed.

xelawho
05-18-2012, 03:37 AM
Oh for crying out loud!

This is COMPLETELY DIFFERENT than what you showed before!

NOW it makes sense. NOW you have THREE choices in each set of options.

Before you had it divided 4 and 2, and as I pointed out with 4 and 2 you can run out of choices in the 2 side!

Sheesh.

But okay, now that it makes sense, it's really easy. And can be done in a lot less code than iBall showed.

to my eye, the "solution" bears very little resemblance to the description in any part of the thread - but hey, if Michelle from Ohio is happy, who are we to complain?

Old Pedant
05-18-2012, 04:33 AM
Well...I take it back. Not a LOT less code than iBall showed, but less code. And I think easier to understand.


<!DOCTYPE html>
<html>
<body>
<h2>This is choice number <span id="count"></span></h2>
<br/>
<form id="theForm">
Which would you rather do:
<br/>
<input type="button" name="opt1"/>
<br/>or<br/>
<input type="button" name="opt2"/>
</form>
<hr/>
Your choices:
<div id="choices"></div>

<script type="text/javascript">
// these are the base sets:
var master1 = ["Doctor's appointment","Going out for most awaited shopping","Login on Facebook"];
var master2 = ["Studying for the exam","Replying to text msgs","Going out with friends"];

var set1 = master1; // just to get things started
var set2 = master2;
var choiceCount = 1;

var f = document.getElementById("theForm")
f.opt1.onclick = choose1;
f.opt2.onclick = choose2;

function choose1() { choose(set1=set1.slice(1)); }
function choose2() { choose(set2=set2.slice(1)); }


function choose(which)
{
if ( which.length == 0 )
{
cycle( );
} else {
again( );
}
}

function again( )
{
f.opt1.value = set1[0];
f.opt2.value = set2[0];
document.getElementById("count").innerHTML = choiceCount;
}

function cycle( )
{
var remove = ( set1.length == 0 ) ? f.opt1.value : f.opt2.value;
var master = ( set1.length == 0 ) ? master1 : master2;
master.splice( master.indexOf(remove), 1 );

document.getElementById("choices").innerHTML +=
"Choice " + choiceCount + ": " + remove + "<br/>";
++choiceCount;
if ( choiceCount < 4 )
{
set1 = master1;
set2 = master2;
again();
} else {
f.opt1.onclick = null;
f.opt2.onclick = null;
}
}
// get started:
again();
</script>
</body>
</html>

xelawho
05-18-2012, 09:53 AM
see, I was thinking she was talking about this:



<!doctype html>
<html>
<head>

</head>

<body onload="display()">
<form name="theform">
Please note your preference: <br>
<input type='radio' name='rad' onclick='choose(1)'/><span id="opt1"></span>
<input type='radio' name='rad' onclick='choose(0)'/><span id="opt2"></span>
</form>
<div id="results"></div>

<script type="text/javascript">
var opts=["Doctors appointment", "studying for the exam","Going out for most awaited shopping", "Login on Facebook","Replying to text msgs", "Go out with friends"]
var rejects=[];
var choices=0;

function choose(idx) {
rejects.push(opts.splice(idx,1));

if (opts.length==1){
document.getElementById("results").innerHTML+="Preference " + (++choices) + " is " +opts.splice(0,1) +"<br>"
for (i = rejects.length - 1; i>=0; i--) {
opts.push(rejects.splice(i,1))
}
}
document.theform.reset();
display();
}

function display(){
if (choices==3){
document.theform.style.display="none"
} else{
document.getElementById("opt1").innerHTML=opts[0]
document.getElementById("opt2").innerHTML=opts[1]
}
}

</script>
</body>
</html>


but anyway. that's enough homework for tonight :rolleyes:

felgall
05-18-2012, 10:11 AM
<body onload="display()">


Since the script is below the form and calls display() at the end anyway that onload can be disposed of without affecting anything else.

The body tag should always be coded as <body> as there is never any need to attach anything into it. There's always a better way to process anything than adding it into the onload tag but in this instance it is completely unnecessary and so can be removed without being replaced with anything elsewhere..

Michelle.G
05-18-2012, 10:54 AM
Thank you every body especially iBall, xelawho, Old Pedant!! :thumbsup:

I am trying to code on the basis of iBalls first post and that is what I exactly wanted... thankss alott...

xelawho
05-18-2012, 03:20 PM
Since the script is below the form and calls display() at the end anyway that onload can be disposed of without affecting anything else.

The body tag should always be coded as <body> as there is never any need to attach anything into it. There's always a better way to process anything than adding it into the onload tag but in this instance it is completely unnecessary and so can be removed without being replaced with anything elsewhere..

errh... I'm half way with you. While there are certainly less clumsy ways of calling a function as the page loads, I think you'll find that simply removing that function call from the body tag without replacing it with one of those other methods would lead to a significant loss in functionality...

point taken. just sayin'

Michelle.G
05-23-2012, 04:25 PM
hey! :) sorry for the late reply...

but I am stuck again as I tried to improve the functionality of the program..but is not working as I thought :(

and how can I store the results in three separate variables in the end??

Please check my code!!




<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Check Your Self</title>

<style type="text/css">
#txt { background-color: #FFFFF1;
border: 2px solid #C3C3C3;
color: #000000;
height: 20px;
width: 450px;
}

</style>

</head>

<body>
<h1> Priority Management </h1>
<br> </br>
<br> </br>

<h3> Your First Priority </h3>
<input type = "text" id = "txt" onchange = "p1(this.value)">
<br> </br>

<h3> Your Second Priority </h3>
<input type = "text" id = "txt" onchange = "p2(this.value)">
<br> </br>

<h3> Your Third Priority </h3>
<input type = "text" id = "txt" onchange = "p3(this.value)">
<br> </br>

<h3> Your Fourth Priority </h3>
<input type = "text" id = "txt" onchange = "p4(this.value)">
<br> </br>

<h3> Your Fifth Priority </h3>
<input type = "text" id = "txt" onchange = "p5(this.value)">
<br> </br>

<h3> Your Sixth Priority </h3>
<input type = "text" id = "txt" onchange = "p6(this.value)">

<br> </br>
<br> </br>

<h2> Your Result </h2>

<br>

<h3 id = p1r></h3>

<br>

<h3 id = p2r></h3>

<br>

<h3 id = p3r></h3>

<br>

<h3 id = p4r></h3>

<br>

<h3 id = p5r></h3>

<br>

<h3 id = p6r></h3>

<br>

<body ="display()">
<form name="theform">
What is more important to you?: <br>
<input type='radio' name='rad' onclick='choose(1)'/><span id="opt1"></span>
<br> </br>
<input type='radio' name='rad' onclick='choose(0)'/><span id="opt2"></span>
</form>
<div id="results"></div>

</body>



<script type = "text/javascript">

var val1;
var val2;
var val3;
var val4;
var val5;
var val6


function p1 (val1) {
document.getElementById("p1r").innerHTML = val1;
}


function p2 (val2) {
document.getElementById("p2r").innerHTML = val2;
}


function p3 (val3) {
document.getElementById("p3r").innerHTML = val3;
}


function p4 (val3) {
document.getElementById("p4r").innerHTML = val3;
}

function p5 (val3) {
document.getElementById("p5r").innerHTML = val3;
}

function p6 (val3) {
document.getElementById("p6r").innerHTML = val3;
}

var opts=[val1, val2, val3, val4, val5, val6];
var rejects=[];
var choices=0;

function choose(idx) {
rejects.push(opts.splice(idx,1));

if (opts.length==1){
document.getElementById("results").innerHTML+="Preference " + (++choices) + " is " +opts.splice(0,1) +"<br>"
for (i = rejects.length - 1; i>=0; i--) {
opts.push(rejects.splice(i,1))
}
}
document.theform.reset();
display();
}

function display(){
if (choices==3){
document.theform.style.display="none"
} else{
document.getElementById("opt1").innerHTML=opts[0]
document.getElementById("opt2").innerHTML=opts[1]
}
}

</script>
</html>

xelawho
05-23-2012, 07:04 PM
not really getting those h3's but maybe...



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Check Your Self</title>

<style type="text/css">
#results { display:none;
}
form{ display:none;
}

</style>

</head>

<body>
<h1> Priority Management </h1>
<br> </br>
<br> </br>
<div id="inps">
<h3> Your First Priority </h3>
<input type = "text">
<br> </br>

<h3> Your Second Priority </h3>
<input type = "text">
<br> </br>

<h3> Your Third Priority </h3>
<input type = "text">
<br> </br>

<h3> Your Fourth Priority </h3>
<input type = "text">
<br> </br>

<h3> Your Fifth Priority </h3>
<input type = "text">
<br> </br>

<h3> Your Sixth Priority </h3>
<input type = "text">
</div>
<br> </br>
<br> </br>

<h2> Your Result </h2>

<br>
<div id="preview">
<h3></h3>
<br>
<h3></h3>
<br>
<h3></h3>
<br>
<h3></h3>
<br>
<h3></h3>
<br>
<h3></h3>
</div>
<br>

<body>
<form name="theform">
What is more important to you?: <br>
<input type='radio' name='rad' onclick='choose(1)'/><span id="opt1"></span>
<br> </br>
<input type='radio' name='rad' onclick='choose(0)'/><span id="opt2"></span>
</form>
<div id="results"></div>

</body>



<script type = "text/javascript">

var heads=document.getElementById("preview").getElementsByTagName("h3")
var boxes=document.getElementById("inps").getElementsByTagName("input")
var opts=[];
var rejects=[];
var choices=0;


for (var i = 0; i < boxes.length; i++) {
boxes[i].onchange=function(i){
return function() {
opts[i]=boxes[i].value;
heads[i].innerHTML=boxes[i].value;
if (opts[5]!=undefined){
document.getElementById("inps").style.display="none"
document.theform.style.display="block"
display()
}
}
}(i)
}

function choose(idx) {
rejects.push(opts.splice(idx,1));

if (opts.length==1){
document.getElementById("results").innerHTML+="Preference " + (++choices) + " is " +opts.shift() +"<br>"
for (i = rejects.length - 1; i>=0; i--) {
opts.push(rejects.shift())
}
}
document.theform.reset();
display();
}

function display(){
if (choices==3){
document.theform.style.display="none"
document.getElementById("results").style.display="block"
} else{
document.getElementById("opt1").innerHTML=opts[0]
document.getElementById("opt2").innerHTML=opts[1]
}
}

</script>
</html>

Michelle.G
05-23-2012, 07:50 PM
not really getting those h3's but maybe...



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Check Your Self</title>

<style type="text/css">
#results { display:none;
}
form{ display:none;
}

</style>

</head>

<body>
<h1> Priority Management </h1>
<br> </br>
<br> </br>
<div id="inps">
<h3> Your First Priority </h3>
<input type = "text">
<br> </br>

<h3> Your Second Priority </h3>
<input type = "text">
<br> </br>

<h3> Your Third Priority </h3>
<input type = "text">
<br> </br>

<h3> Your Fourth Priority </h3>
<input type = "text">
<br> </br>

<h3> Your Fifth Priority </h3>
<input type = "text">
<br> </br>

<h3> Your Sixth Priority </h3>
<input type = "text">
</div>
<br> </br>
<br> </br>

<h2> Your Result </h2>

<br>
<div id="preview">
<h3></h3>
<br>
<h3></h3>
<br>
<h3></h3>
<br>
<h3></h3>
<br>
<h3></h3>
<br>
<h3></h3>
</div>
<br>

<body>
<form name="theform">
What is more important to you?: <br>
<input type='radio' name='rad' onclick='choose(1)'/><span id="opt1"></span>
<br> </br>
<input type='radio' name='rad' onclick='choose(0)'/><span id="opt2"></span>
</form>
<div id="results"></div>

</body>



<script type = "text/javascript">

var heads=document.getElementById("preview").getElementsByTagName("h3")
var boxes=document.getElementById("inps").getElementsByTagName("input")
var opts=[];
var rejects=[];
var choices=0;


for (var i = 0; i < boxes.length; i++) {
boxes[i].onchange=function(i){
return function() {
opts[i]=boxes[i].value;
heads[i].innerHTML=boxes[i].value;
if (opts[5]!=undefined){
document.getElementById("inps").style.display="none"
document.theform.style.display="block"
display()
}
}
}(i)
}

function choose(idx) {
rejects.push(opts.splice(idx,1));

if (opts.length==1){
document.getElementById("results").innerHTML+="Preference " + (++choices) + " is " +opts.shift() +"<br>"
for (i = rejects.length - 1; i>=0; i--) {
opts.push(rejects.shift())
}
}
document.theform.reset();
display();
}

function display(){
if (choices==3){
document.theform.style.display="none"
document.getElementById("results").style.display="block"
} else{
document.getElementById("opt1").innerHTML=opts[0]
document.getElementById("opt2").innerHTML=opts[1]
}
}

</script>
</html>



Thanks :D

but is there a way to store the results say preference 1, preference 2, preference 3 in separate variable so that they can be used further if required...
and also show the result say preference 1 once selected and then start the loop for preference 2 and so on...

xelawho
05-23-2012, 07:58 PM
stores preferences in the prefs array (first preference is prefs[0], etc):



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Check Your Self</title>

<style type="text/css">
form{ display:none;
}

</style>

</head>

<body>
<h1> Priority Management </h1>
<br> </br>
<br> </br>
<div id="inps">
<h3> Your First Priority </h3>
<input type = "text">
<br> </br>

<h3> Your Second Priority </h3>
<input type = "text">
<br> </br>

<h3> Your Third Priority </h3>
<input type = "text">
<br> </br>

<h3> Your Fourth Priority </h3>
<input type = "text">
<br> </br>

<h3> Your Fifth Priority </h3>
<input type = "text">
<br> </br>

<h3> Your Sixth Priority </h3>
<input type = "text">
</div>
<br> </br>
<br> </br>

<h2> Your Result </h2>

<br>
<div id="preview">
<h3></h3>
<br>
<h3></h3>
<br>
<h3></h3>
<br>
<h3></h3>
<br>
<h3></h3>
<br>
<h3></h3>
</div>
<br>

<body>
<form name="theform">
What is more important to you?: <br>
<input type='radio' name='rad' onclick='choose(1)'/><span id="opt1"></span>
<br> </br>
<input type='radio' name='rad' onclick='choose(0)'/><span id="opt2"></span>
</form>
<div id="results"></div>

</body>



<script type = "text/javascript">

var heads=document.getElementById("preview").getElementsByTagName("h3")
var boxes=document.getElementById("inps").getElementsByTagName("input")
var opts=[];
var rejects=[];
var choices=0;
var prefs=[];


for (var i = 0; i < boxes.length; i++) {
boxes[i].onchange=function(i){
return function() {
opts[i]=boxes[i].value;
heads[i].innerHTML=boxes[i].value;
if (opts[5]!=undefined){
document.getElementById("inps").style.display="none"
document.theform.style.display="block"
display()
}
}
}(i)
}

function choose(idx) {
rejects.push(opts.splice(idx,1));

if (opts.length==1){
prefs.push(opts.shift())
document.getElementById("results").innerHTML+="Preference " + (++choices) + " is " +prefs[prefs.length-1] +"<br>"
for (i = rejects.length - 1; i>=0; i--) {
opts.push(rejects.shift())
}
}
document.theform.reset();
display();
}

function display(){
if (choices==3){
document.theform.style.display="none"
} else{
document.getElementById("opt1").innerHTML=opts[0]
document.getElementById("opt2").innerHTML=opts[1]
}
}

</script>
</html>

Michelle.G
05-23-2012, 08:03 PM
stores preferences in the prefs array (first preference is prefs[0], etc):



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Check Your Self</title>

<style type="text/css">
form{ display:none;
}

</style>

</head>

<body>
<h1> Priority Management </h1>
<br> </br>
<br> </br>
<div id="inps">
<h3> Your First Priority </h3>
<input type = "text">
<br> </br>

<h3> Your Second Priority </h3>
<input type = "text">
<br> </br>

<h3> Your Third Priority </h3>
<input type = "text">
<br> </br>

<h3> Your Fourth Priority </h3>
<input type = "text">
<br> </br>

<h3> Your Fifth Priority </h3>
<input type = "text">
<br> </br>

<h3> Your Sixth Priority </h3>
<input type = "text">
</div>
<br> </br>
<br> </br>

<h2> Your Result </h2>

<br>
<div id="preview">
<h3></h3>
<br>
<h3></h3>
<br>
<h3></h3>
<br>
<h3></h3>
<br>
<h3></h3>
<br>
<h3></h3>
</div>
<br>

<body>
<form name="theform">
What is more important to you?: <br>
<input type='radio' name='rad' onclick='choose(1)'/><span id="opt1"></span>
<br> </br>
<input type='radio' name='rad' onclick='choose(0)'/><span id="opt2"></span>
</form>
<div id="results"></div>

</body>



<script type = "text/javascript">

var heads=document.getElementById("preview").getElementsByTagName("h3")
var boxes=document.getElementById("inps").getElementsByTagName("input")
var opts=[];
var rejects=[];
var choices=0;
var prefs=[];


for (var i = 0; i < boxes.length; i++) {
boxes[i].onchange=function(i){
return function() {
opts[i]=boxes[i].value;
heads[i].innerHTML=boxes[i].value;
if (opts[5]!=undefined){
document.getElementById("inps").style.display="none"
document.theform.style.display="block"
display()
}
}
}(i)
}

function choose(idx) {
rejects.push(opts.splice(idx,1));

if (opts.length==1){
prefs.push(opts.shift())
document.getElementById("results").innerHTML+="Preference " + (++choices) + " is " +prefs[prefs.length-1] +"<br>"
for (i = rejects.length - 1; i>=0; i--) {
opts.push(rejects.shift())
}
}
document.theform.reset();
display();
}

function display(){
if (choices==3){
document.theform.style.display="none"
} else{
document.getElementById("opt1").innerHTML=opts[0]
document.getElementById("opt2").innerHTML=opts[1]
}
}

</script>
</html>



Super Thanks xelawho :thumbsup::D:thumbsup:

Thanks for the explanation!! about the array being used..

Michelle.G
05-27-2012, 12:27 AM
Please Help!!!

buttons not showing the value as expected :(



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Check Your Self</title>

<style type="text/css">
form{ display:none;
}

</style>

</head>

<body>
<h1> Priority Management </h1>
<br> </br>
<br> </br>
<div id="inps">
<h3> Your First Priority </h3>
<input type = "text">
<br> </br>

<h3> Your Second Priority </h3>
<input type = "text">
<br> </br>

<h3> Your Third Priority </h3>
<input type = "text">
<br> </br>

<h3> Your Fourth Priority </h3>
<input type = "text">
<br> </br>

<h3> Your Fifth Priority </h3>
<input type = "text">
<br> </br>

<h3> Your Sixth Priority </h3>
<input type = "text">
</div>
<br> </br>
<br> </br>

<h2> Your Result </h2>

<br>
<div id="preview">
<h3></h3>
<br>
<h3></h3>
<br>
<h3></h3>
<br>
<h3></h3>
<br>
<h3></h3>
<br>
<h3></h3>
</div>
<br>

<body>
<form name="theform">
What is more important to you?: <br>
<input type='button' name='rad1' onclick='choose(1)'/>
<br> </br>
<input type='button' name='rad2' onclick='choose(0)'/>
</form>
<div id="results"></div>

</body>



<script type = "text/javascript">

var heads=document.getElementById("preview").getElementsByTagName("h3")
var boxes=document.getElementById("inps").getElementsByTagName("input")
var opts=[];
var rejects=[];
var choices=0;
var prefs=[];


for (var i = 0; i < boxes.length; i++) {
boxes[i].onchange=function(i){
return function() {
opts[i]=boxes[i].value;
heads[i].innerHTML=boxes[i].value;
if (opts[5]!=undefined){
document.getElementById("inps").style.display="none"
document.theform.style.display="block"
display()
}
}
}(i)
}

function choose(idx) {
rejects.push(opts.splice(idx,1));

if (opts.length==1){
prefs.push(opts.shift())
document.getElementById("results").innerHTML+="Preference " + (++choices) + " is " +prefs[prefs.length-1] +"<br>"
for (i = rejects.length - 1; i>=0; i--) {
opts.push(rejects.shift())
}
}
document.theform.reset();
display();
}

function display(){
if (choices==3){
document.theform.style.display="none"
} else{
f.rad1.value=opts[0]
f.rad2.value=opts[1]
}
}

</script>
</html>


Please Check this:



<body>
<form name="theform">
What is more important to you?: <br>
<input type='button' name='rad1' onclick='choose(1)'/>
<br> </br>
<input type='button' name='rad2' onclick='choose(0)'/>
</form>
<div id="results"></div>

</body>


and this is the script change:



function display(){
if (choices==3){
document.theform.style.display="none"
} else{
f.rad1.value=opts[0]
f.rad2.value=opts[1]
}



Please help! :(

xelawho
05-27-2012, 12:53 AM
what is f?



document.theform.rad1.value=opts[0]
document.theform.rad2.value=opts[1]

Michelle.G
05-27-2012, 01:01 AM
what is f?



document.theform.rad1.value=opts[0]
document.theform.rad2.value=opts[1]



hey! thnx

my mistake I took f as a shorthand from my reference guide where as it was something else..

thanks for rectifying :)

Michelle.G
05-28-2012, 04:48 PM
Hi! I am stuck again on another point in the program :(

Status:
jquery accordion working fine :) but javascript is not working :(

Need Help to work both!



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Check Your Self</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js"></script>
<script src="/script.js"></script>
<script>
$(function() {
$( "#ad" ).accordion();
});
</script>

<style type="text/css">
h3 {
font-family: verdana,sans-serif;
color: #FFA640;
font-size: 26px;
font-weight: bold;
letter-spacing: 1.4pt;
word-spacing: 2pt;
line-height: 2;
cursor:pointer;
}

</style>

</head>

<body>
<div id=ad>
<h3><a hef="#">Priority Management</a></h3>
<div id="inps">
<h2> Your First Priority </h2>
<input type = "text">
<br> </br>

<h2> Your Second Priority </h2>
<input type = "text">
<br> </br>

<h2> Your Third Priority </h2>
<input type = "text">
<br> </br>

<h2> Your Fourth Priority </h2>
<input type = "text">
<br> </br>

<h2> Your Fifth Priority </h2>
<input type = "text">
<br> </br>

<h2> Your Sixth Priority </h2>
<input type = "text">
</div>

<h3><a hef="#"> Your Result</a></h3>
<div id="preview">
<h4></h4>
<br>
<h4></h4>
<br>
<h4></h4>
<br>
<h4></h4>
<br>
<h4></h4>
<br>
<h4></h4>
</div>

<h3><a hef="#">Choose what are Important to you!</a></h3>
<div id="choose">
<form name="theform">
What is more important to you?: <br>
<input type='button' name='rad1' onclick='choose(1)'/>
<br> </br>
<input type='button' name='rad2' onclick='choose(0)'/>
</form>
<div id="results"></div>
</div>

<h3><a hef="#">About your 1st Priority</a></h3>
<div id="prefs1">

<input type="text" name="prefs1"/> <p> : some content some content some content some content some content some content </p>
<br>
<p>ome content some content some content some content some content some content </p>
<br>
<p>ome content some content some content some content some content some content </p>
</div>

<h3><a hef="#">About your 2nd Priority</a></h3>
<div id="prefs2">

<input type="text" name="prefs2"/> <p> : some content some content some content some content some content some content </p>
<br>
<p>ome content some content some content some content some content some content </p>
<br>
<p>ome content some content some content some content some content some content </p>
</div>

<h3><a hef="#">About your 3rd Priority</a></h3>
<div id="prefs3">

<input type="text" name="prefs3"/> <p> : some content some content some content some content some content some content </p>
<br>
<p>ome content some content some content some content some content some content </p>
<br>
<p>ome content some content some content some content some content some content </p>
</div>
</div>

</body>

</html>


This is the script.js file!:


<script type = "text/javascript">

var heads=document.getElementById("preview").getElementsByTagName("h3")
var boxes=document.getElementById("inps").getElementsByTagName("input")
var opts=[];
var rejects=[];
var choices=0;
var prefs=[];


for (var i = 0; i < boxes.length; i++) {
boxes[i].onchange=function(i){
return function() {
opts[i]=boxes[i].value;
heads[i].innerHTML=boxes[i].value;
if (opts[5]!=undefined){
document.getElementById("inps").style.display="none"
document.theform.style.display="block"
display()
}
}
}(i)
}

function choose(idx) {
rejects.push(opts.splice(idx,1));

if (opts.length==1){
prefs.push(opts.shift())
document.getElementById("results").innerHTML+="Preference " + (++choices) + " is " +prefs[prefs.length-1] +"<br>"
document.thefom.prefs1.value=prefs[0]
document.theform.prefs2.value=prefs[1]
document.theform.prefs3.value=prefs[2]
for (i = rejects.length - 1; i>=0; i--) {
opts.push(rejects.shift())
}
}
document.theform.reset();
display();
}

function display(){
if (choices==3){
document.theform.style.display="none"
} else{
document.theform.rad1.value=opts[0]
document.theform.rad2.value=opts[1]

}
}

</script>


Please help to fix this :(

Michelle.G
05-29-2012, 03:39 PM
Hi! guys...

Please any solution to the problem?? :(

Update:
The script works fine if I put it inline between 2nd h3 and 3rd h3..but accordion stops working after the 3rd h3 :(


Please, please help! :(

Michelle.G
06-04-2012, 07:26 AM
Hieee! friends, made the JavaScript as well as the jQuery accordion working together :)

but need small help with these popups that I have created to alert the user when he does not fill in data in all the six input area under div id ="inps" before he proceeds to the choice part under div id="choose" but they are acting not the way I had expected :(

Need help to create popup that pops up only when the user clicks one of the buttons (rad1, rad2) inside div id="choose" and have not filled all the input areas under div id ="inps"




<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Check Your Self</title>


<style type="text/css">
h3 a{
font-family: verdana,sans-serif;
color: #FFA640;
font-size: 26px;
font-weight: bold;
letter-spacing: 1.4pt;
word-spacing: 2pt;
line-height: 2;
cursor:pointer;
}

</style>

</head>

<body>

<div id="ad">
<h3><a href="#">Priority Management</a></h3>

<div id="inps">
<h4> Your First Priority </h4>
<input type = "text"/>
<br> </br>

<h4> Your Second Priority </h4>
<input type = "text"/>
<br> </br>

<h4> Your Third Priority </h4>
<input type = "text"/>
<br> </br>

<h4> Your Fourth Priority </h4>
<input type = "text"/>
<br> </br>

<h4> Your Fifth Priority </h4>
<input type = "text"/>
<br> </br>

<h4> Your Sixth Priority </h4>
<input type = "text"/>
</div>


<h3><a href="#"> Your Result</a></h3>


<div id="preview">
<h2></h2>
<br>
<h2></h2>
<br>
<h2></h2>
<br>
<h2></h2>
<br>
<h2></h2>
<br>
<h2></h2>
</div>

<h3><a href="#">Choose what are Important to you!</a></h3>

<div id="choose">

<form name="theform">
What is more important to you?: <br> </br>
<input type='button' name='rad1' onclick='choose(1)'/>
<br> </br>
<br> </br>
<input type='button' name='rad2' onclick='choose(0)'/>
</form>

<div id="results"></div>

</div>

<h3><a href="#">About your 1st Priority</a></h3>

<div>

<input type="text" id="prefs1"/> <p> : some content some content some content some content some content some content </p>
<br>
<p>ome content some content some content some content some content some content </p>
<br>
<p>ome content some content some content some content some content some content </p>
</div>


<h3><a href="#">About your 2nd Priority</a></h3>

<div>

<input type="text" id="prefs2"/> <p> : some content some content some content some content some content some content </p>
<br>
<p>ome content some content some content some content some content some content </p>
<br>
<p>ome content some content some content some content some content some content </p>
</div>



<h3><a href="#">About your 3rd Priority</a></h3>


<div>

<input type="text" id="prefs3"/> <p> : some content some content some content some content some content some content </p>
<br>
<p>ome content some content some content some content some content some content </p>
<br>
<p>ome content some content some content some content some content some content </p>
</div>


</div>



</div>

</body>



<script type = "text/javascript">

var heads=document.getElementById("preview").getElementsByTagName("h2")
var boxes=document.getElementById("inps").getElementsByTagName("input")
var opts=[];
var rejects=[];
var choices=0;
var prefs=[];


for (var i = 0; i < boxes.length; i++) {
boxes[i].onchange=function(i){
return function() {
opts[i]=boxes[i].value;
heads[i].innerHTML=boxes[i].value;
if (opts[5]!=undefined){
document.theform.style.display="block"
display()
} else {
alert("Step 1 error: Please fill all the columns in step 1");
}
}
}(i)
}

function choose(idx) {

rejects.push(opts.splice(idx,1));

if (opts.length==1){
prefs.push(opts.shift())
document.getElementById("results").innerHTML+="Preference " + (++choices) + " is " +prefs[prefs.length-1] +"<br>"
document.getElementById("prefs1").value=prefs[0]
document.getElementById("prefs2").value=prefs[1]
document.getElementById("prefs3").value=prefs[2]
for (i = rejects.length - 1; i>=0; i--) {
opts.push(rejects.shift())
}
}
document.theform.reset();
display();
}

function display(){
if (choices==3){
document.theform.style.display="none"
} else{
document.theform.rad1.value=opts[0]
document.theform.rad2.value=opts[1]
}
}

</script>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js"></script>

<script>
$(function() {
$( "#ad" ).accordion();
});
</script>

</html>





help is appreciated :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum