Closed Thread Icon

Preserved Topic: Advice/Input please... step by step tool.. (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=18423" title="Pages that link to Preserved Topic: Advice/Input please... step by step tool.. (Page 1 of 1)" rel="nofollow" >Preserved Topic: Advice/Input please... step by step tool.. <span class="small">(Page 1 of 1)</span>\

 
sonicsnail
Bipolar (III) Inmate

From: Scotland
Insane since: Jun 2001

posted posted 09-26-2002 21:10

Hi all,

Ok, I'm creating a tool that guides people through a Problem Solving Process.

The user chooses a technical problem which lands them on a page that would like (roughly) like this:



---

The theory:

The user completes the first step, and ticks a "yes" or "no" option - and the page offers step 2. Step 2 could be one of 2 things (depending if they chose yes or no). Now they answer Step 2, which, again, offers the next step (1 of 2 possibilites again).. and so on and so on...

The "Steps" appear one under the other.

---

My solution:

(bad syntax code coming up!)

A load of <div>s with their style property "display" set to "none", holding the "Steps". Each with a unique name of course.

All the checkboxes have an Onclick event that sets the style of the relevant <div> to display.

---

So thats how I'm going to do it...

I know this is pretty simple, and typing this out has actually helped me understand what I have to do, but where I hope you can help is in producing some nice neat code rather than the oversize non-looping efforts that I usually create - 1 function for every onclick event kind of crap.

Tips would be greatly appreciated,

Pete



lallous
Paranoid (IV) Inmate

From: Lebanon
Insane since: May 2001

posted posted 09-27-2002 08:57

I got lots of ideas on how to solve this, but I don't have enough data/entries from you...

suggestion #1: do not use <div> tags and stuff....
simply use Arrays that holds the set of questions and their answers or next set of questions...

try to give me more data


InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 09-27-2002 09:14

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

sonicsnail
Bipolar (III) Inmate

From: Scotland
Insane since: Jun 2001

posted posted 09-27-2002 10:00

Lallous:

Data.. hmmm.. hard to document so I'll provide a silly example.

Damn.. I can't write this logically without a flow chart!

Think about cooking an egg: (I'm going to write this without all the available options, but following one logical path..)

Prepare a cooking pan {Frying

lallous
Paranoid (IV) Inmate

From: Lebanon
Insane since: May 2001

posted posted 09-27-2002 11:16

Would this help?
http://www.developersdex.com/asp/message.asp?p=2978&ID=%3C69476b6f%2E0209262348%2E3dc8ae40%40posting%2Egoogle%2Ecom%3E

see my approach.

sonicsnail
Bipolar (III) Inmate

From: Scotland
Insane since: Jun 2001

posted posted 09-27-2002 11:40

looks interesting... I'll try to chew it over..

I created this sample for you to look at how I am/was intending to do it...

Pretty messy I think you'll agree. - I also have to make sure I declare the <div>s in the correct order - otherwise a new one could appear above the one you clicked.

Click here to see it in action

Speaking of arrays, can I declare all this stuff in one go - kind of like your link, ie:

functionShowStuff(Layername, option1, option2, Text Content) - kind of thing?? That would allow me to write them on the fly wouldn't it?? (and DEFINATELY below the last one clicked))

code:
<html>
<head><title>STEPbySTEP II Beta</title>

<script>
function showORhide(whichone){
if (whichone.style.display == "none") {
whichone.style.display = "block";
} else {
whichone.style.display = "none";
}
}

</script>

</head>
<body>

<h2>Cooking an Egg!</h2>

<div id="first" style="display:show">
<table width="500" border="1"><tr>

<td width="300">Prepare a cooking pan</td>
<td width="100" align="center">Boiling<br><input type="checkbox" onclick="showORhide(boiling)"></td>
<td width="100" align="center">Frying<Br><input type="checkbox" onclick="showORhide(frying)"></td>
</tr></table>
</div>

<div id="frying"style="display:none">
<table width="500" border="1"><tr>
<td width="300">Add oil to frying pan</td>
<td width="100" align="center">Olive Oil<br><input type="checkbox" onclick="showORhide(OliveOil)"></td>
<td width="100" align="center">Veg. Oil<br><input type="checkbox" onclick="showORhide(VegOil)"></td>
</tr></table>
</div>

<div id="boiling" style="display:none">
<table width="500" border="1"><tr>
<td width="300">Add plenty water</td>
<td width="100" align="center">Hot<br><input type="checkbox" onclick="showORhide(hotwater)"></td>
<td width="100" align="center">Cold<br><input type="checkbox" onclick="showORhide(coldwater)"></td>
</tr></table>
</div>

<div id="VegOil" style="display:none">
<table width="500" border="1"><tr>
<td width="300">Heat oil to *very hot*</td>
<td width="200" align="center">OK<br><input type="checkbox" onclick="showORhide(breakegg)"></td>
</tr></table>
</div>


<div id="OliveOil" style="display:none">
<table width="500" border="1"><tr>
<td width="300">Heat oil to *quite hot*</td>
<td width="200" align="center">OK<br><input type="checkbox" onclick="showORhide(breakegg)"></td>
</tr></table>
</div>

<div id="coldwater" style="display:none">
<table width="500" border="1"><tr>
<td width="300">Bring your water to the boiling point</td>
<td width="100" align="center">OK<br><input type="checkbox" onclick="showORhide(hotwater)"></td>
</tr></table>
</div>

<div id="hotwater" style="display:none">
<table width="500" border="1"><tr>
<td width="300">Drop in your egg, shell + all.</td>
<td width="200" align="center">OK<br><input type="checkbox" onclick="showORhide(sodboiling)"></td>
</tr></table>
</div>

<div id="sodboiling" style="display:none">
<table width="500" border="1"><tr>
<td width="500">ah forget it, I don't like boiled eggs.
Throw that one away and get on with frying - much more healthy.</td>
</tr></table>
</div>

<div id="breakegg" style="display:none">
<table width="500" border="1"><tr>
<td width="300">Break your egg into pan</td>
<td width="100" align="center">Yoke Intact<br><input type="checkbox" onclick="showORhide(yokeintact)"></td>
<td width="100" align="center">Yoke Broken<br><input type="checkbox" onclick="showORhide(yokebroken)"></td>
</tr></table>
</div>

<div id="yokeintact" style="display:none">
<table width="500" border="1"><tr>
<td width="300">Give it a couple of minutes</td>
<td width="200" align="center">OK<br><input type="checkbox" onclick="showORhide(finished)"></td>
</tr></table>
</div>

<div id="yokebroken" style="display:none">
<table width="500" border="1"><tr>
<td width="300">Pile Egg into Lump</td>
<td width="100" align="center">Looks Good<br><input type="checkbox" onclick="showORhide(finished)"></td>
<td width="100" align="center">Looks Crap<br><input type="checkbox" onclick="showORhide(finished)"></td>
</tr></table>
</div>

<div id="finished" style="display:none">
<table width="500" border="1"><tr>
<td width="500"><b>You're done! Eat it! Faster!</b></td></tr></table>
</div>

</body>
</html>




cheers,

Pete




[This message has been edited by sonicsnail (edited 09-27-2002).]

Hugh
Paranoid (IV) Inmate

From: Dublin, Ireland
Insane since: Jul 2000

posted posted 09-27-2002 13:20

Sonic Snail : Nice sig by the way

Thats all I have to say really.

sonicsnail
Bipolar (III) Inmate

From: Scotland
Insane since: Jun 2001

posted posted 09-29-2002 22:23

I've read a tut on "object orientated programming" in JS, and I'm buckling my brain trying to get this working in that form... I'll post the page if/when I get it to work.

I've got my fingers crossed for some more asylum assistance on this one though.... pretty please.

sonicsnail
Bipolar (III) Inmate

From: Scotland
Insane since: Jun 2001

posted posted 09-29-2002 23:45

Ok boys and girls...
http://www.it-forums.org/pete/ozone/index2.htm

Before you shout "nothing there" - have a look at the source.

I think I should be able to document.write all of the boxes using that code - however if I *do* get it to write them all, it "writes" after the page has loaded, so I lose everything else on the page...

The other issue is: I need the first "Step" to appear visible, with the others invisible. My current code won't do that, it'll just loop through the whole lot with the same "display" setting. My solution to this is to have the first Step actually rendered on the page in the main HTML body. BUT then I have to document.write AFTER the first box... AAARRRGGGHHH

I'm trying really hard here folks... but please help (I reckon I'm not tooo far off the mark)

Thanks, Pete.

here's the code:

code:
<html>
<head>
<title>STEPbySTEP II</title>

<script>

function STEPbySTEPfix(name, option1, option2, option3, description)
{
this.name = name
this.option1 = option1
this.option2 = option2
this.option3 = option3
this.description = description
}

var STEPbySTEPfixes = new Array();
STEPbySTEPfixes[STEPbySTEPfixes.length] = new STEPbySTEPfix("cookingmethod", "fry", "boil", "poach", "Choose your cooking method")
STEPbySTEPfixes[STEPbySTEPfixes.length] = new STEPbySTEPfix("fry", "veg oil", "olive oil", "", "which oil are you using?")
STEPbySTEPfixes[STEPbySTEPfixes.length] = new STEPbySTEPfix("boil", "hotwater", "coldwater", "", "are you using hot or cold water")
STEPbySTEPfixes[STEPbySTEPfixes.length] = new STEPbySTEPfix("veg oil", "ok", "", "", "heat the oil very hot")


{
for (var index = 0; index < STEPbySTEPfixes.length; index++)
{
var item = STEPbySTEPfixes[index];
document.write("<div id=" + item.name + " style=\"display:none\"><table border=1 width=300><tr><td width=200>" + item.description + "</td>")
document.write("<td><input type=checkbox onclick=" + item.option1 + "></td><td><input type=checkbox onclick=" + item.option2 + "></td></tr></table>")

}
}

function showORhide(whichone)
{
if (whichone.style.display == "none") {
whichone.style.display = "block";
} else {
whichone.style.display = "none";
}
}


</script>
</head>

<body>

<table width="500" border="1"><tr>
<td width="300">Prepare a cooking pan</td>
<td width="100" align="center">Boiling<br><input type="checkbox" onclick="showORhide(fry)"></td>
<td width="100" align="center">Frying<Br><input type="checkbox" onclick="showORhide(boil)"></td>
</tr></table>

<a href="#" onclick="showORhide(fry)">START</a>


</body>
</html>



[This message has been edited by sonicsnail (edited 09-29-2002).]

[This message has been edited by sonicsnail (edited 09-29-2002).]

InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 09-30-2002 21:52

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 09-30-2002 22:29

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

sonicsnail
Bipolar (III) Inmate

From: Scotland
Insane since: Jun 2001

posted posted 09-30-2002 23:08

hi InI, thanks for assisting.

I worked very hard to get this to where it is now, and I've probably tripled my knowledge of JS. Believe it or not, I actually got there myself in the end, before you posted ^ .

This is being done for my "job", and I've avoided doing/telling/showing anything I shouldn't online. I've created the newest version of the page with the actual steps involved, and even some of the style elements for the existing site, and I don't want to put it online with this level of detail.

Here's the code though - feel free to paste it into you notepad and test it out! There's no stylesheet or image etc though.

Here's some cool stuff I've started weaving in...

The document.write runs 3 times for every "Step" - because some Steps have 3 tickboxes. Howver, rather than rendering unrequired tickboxes for steps that only require 1 or 2, the script checks if there is a value, and only draws the <td><input... etc if required. This bit made me very happy.

I won't tell you the reasoning in detail, but when ticked, the script also adds a little content to the <textarea> on the right. This I'd achieved in the past however.

You'll get an error at some of the final stages of the steps.. this is because there is extra functionality to go in.

This made me very happy today. At f***ing last!

Thanks all. I appreciate the help, and restraint by others to force me to work this pretty simple stuff out for myself.

code:
<html>
<head>
<title>STEPbySTEP II</title>

<script>

//Declare Objects
function STEPbySTEPfix(name, option1, option2, option3, description, writethis)
{
this.name = name
this.option1 = option1
this.option2 = option2
this.option3 = option3
this.description = description
this.writethis = writethis
}

//Put Objects Into Array to allow loooooping
var STEPbySTEPfixes = new Array();
STEPbySTEPfixes[STEPbySTEPfixes.length] = new STEPbySTEPfix("Off", "CheckedPower", "", "", "Check (power) cabling, powersupply, powercycle", "'checkedrouterlights'")
STEPbySTEPfixes[STEPbySTEPfixes.length] = new STEPbySTEPfix("CheckedPower", "BookFault", "", "", "There is a router fault, Book to WS", "'checkedpower'")
STEPbySTEPfixes[STEPbySTEPfixes.length] = new STEPbySTEPfix("Amber", "CheckedPhone", "", "", "Check phone, wall socket, powercycle", "'stuff'")
STEPbySTEPfixes[STEPbySTEPfixes.length] = new STEPbySTEPfix("CheckedPhone", "Woosh", "", "", "Run Woosh Test", "'stuff'")
STEPbySTEPfixes[STEPbySTEPfixes.length] = new STEPbySTEPfix("Woosh", "BookFault", "", "", "There is a fault, Book to WS", "'stuff'")
STEPbySTEPfixes[STEPbySTEPfixes.length] = new STEPbySTEPfix("Green", "Yes_PwrCycd", "No_PwrCycd", "", "Has your customer already PowerCycled?", "'stuff'")
STEPbySTEPfixes[STEPbySTEPfixes.length] = new STEPbySTEPfix("No_PwrCycd", "Yes_PwrCycd", "", "", "Ask customer to PowerCycle hardware", "'stuff'")
STEPbySTEPfixes[STEPbySTEPfixes.length] = new STEPbySTEPfix("Yes_PwrCycd", "Yes_ConnScreen", "No_ConnScreen", "", "Can customer get Connection Screen?", "'stuff'")
STEPbySTEPfixes[STEPbySTEPfixes.length] = new STEPbySTEPfix("Yes_ConnScreen", "User_PW_Error", "Other_Error", "", "What type of error do they get?", "'stuff'")
STEPbySTEPfixes[STEPbySTEPfixes.length] = new STEPbySTEPfix("Other_Error", "Run_Woosh", "", "", "Run Woosh Test", "'stuff'")
STEPbySTEPfixes[STEPbySTEPfixes.length] = new STEPbySTEPfix("Run_Woosh", "BookFault", "", "", "There is a fault, Book to WS", "'stuff'")
STEPbySTEPfixes[STEPbySTEPfixes.length] = new STEPbySTEPfix("User_PW_Error", "Acc_OK", "Acc_Inactive", "", "Check Account in IDA, retype password", "'stuff'")
STEPbySTEPfixes[STEPbySTEPfixes.length] = new STEPbySTEPfix("Acc_Inactive", "", "", "", "Pull up the account in Fusion and call over a PS who will advise further", "'stuff'")
STEPbySTEPfixes[STEPbySTEPfixes.length] = new STEPbySTEPfix("Acc_OK", "BT_Test_OK", "BT_Test_Fail", "", "Try connecting with test details", "'stuff'")
STEPbySTEPfixes[STEPbySTEPfixes.length] = new STEPbySTEPfix("BT_Test_Fail", "", "", "", "Your customers account is active, they can see the conn screen, yet cant connect with any details. Call over your PS", "'stuff'")
STEPbySTEPfixes[STEPbySTEPfixes.length] = new STEPbySTEPfix("BT_Test_OK", "Test_User_OK", "Test_User_Fail", "", "Test with HG test details", "'stuff'")
STEPbySTEPfixes[STEPbySTEPfixes.length] = new STEPbySTEPfix("Test_User_Fail", "", "", "BookFault", "Your customer has an SSB (Service Select Barring) Problem. Book Fault", "'stuff'")
STEPbySTEPfixes[STEPbySTEPfixes.length] = new STEPbySTEPfix("Test_User_OK", "MegaSt_OK", "MegaSt_Fail", "", "Try connecting with customers details on the megastream", "'stuff'")
STEPbySTEPfixes[STEPbySTEPfixes.length] = new STEPbySTEPfix("MegaSt_Fail", "", "", "", "There is an odd account problem - call over your PS.", "'stuff'")
STEPbySTEPfixes[STEPbySTEPfixes.length] = new STEPbySTEPfix("MegaSt_OK", "", "", "", "There is clearly nothing wrong with the account. There is no SSB issue. The customer must be making a User Error. If you are sure this is not the case, call over your PS.", "'stuff'")
STEPbySTEPfixes[STEPbySTEPfixes.length] = new STEPbySTEPfix("No_ConnScreen", "Regraded_Yes", "Regraded_No", "", "Check Workflow for recent Regrades.", "'bleh'")
STEPbySTEPfixes[STEPbySTEPfixes.length] = new STEPbySTEPfix("Regraded_Yes", "", "", "", "Talk your customer through the complex Regrade process, and how this has affected their service. Call over your PS if necessary.", "'stuff'")
STEPbySTEPfixes[STEPbySTEPfixes.length] = new STEPbySTEPfix("Regraded_No", "IPconfig", "", "", "Run IPConfig.", "'stuff'")
STEPbySTEPfixes[STEPbySTEPfixes.length] = new STEPbySTEPfix("IPconfig", "CheckNetworks", "", "", "Check customers network settings.", "'stuff'")
STEPbySTEPfixes[STEPbySTEPfixes.length] = new STEPbySTEPfix("CheckNetworks", "Ping_Yes", "Ping_No", "", "Can customer ping the router.", "'stuff'")
STEPbySTEPfixes[STEPbySTEPfixes.length] = new STEPbySTEPfix("Ping_Yes", "", "", "", "Check for Browser Issues - If unsure speak to your PS.", "'stuff'")
STEPbySTEPfixes[STEPbySTEPfixes.length] = new STEPbySTEPfix("Ping_No", "CheckCabling", "", "", "Check cabling and hardware.", "'stuff'")
STEPbySTEPfixes[STEPbySTEPfixes.length] = new STEPbySTEPfix("CheckCabling", "", "", "", "This is an odd issue - call over your PS.", "'beh'")


//Function to show/hide layer onclick
function showORhide(whichone)
{
if (whichone.style.display == "none") {
whichone.style.display = "block";
} else {
whichone.style.display = "none";
}
}

//Function to update textarea
function updatetextarea(writeme){
var addText;
addText = writeme;
var revisedMessage;
var currentMessage = document.templates.messageBox.value;
revisedMessage = currentMessage+addText+"\n";
document.templates.messageBox.value=revisedMessage;
document.templates.messageBox.focus();
return;
}

//Function to do it all!
function DoItAll(whichone,writeme)
{
showORhide(whichone);
updatetextarea(writeme)
}

</script><link rel="stylesheet" href="style.css"></head>

<body>

<table width="100%" border="0"><tr><td class="inset" width="100%">
<font color="yellow">STEPbySTEP II - <i>Beta</i>
</td><td align="right" class="Inset">
<table cellpadding="0" cellspacing="0" border="0"><tr><td><FORM ACTION="javascript:history.back(1)" METHOD="get"><INPUT TYPE="SUBMIT" VALUE="BACK" class="button"></td><td></form></td><td> </td><td><FORM ACTION="../index.htm" METHOD="get"><INPUT TYPE="SUBMIT" VALUE="HOME" class="button"></td><td></form></td></tr></table>
</td></tr></table>


<form name=templates>
<table width="100%"><tr><td width="550" valign="top">

<!-- This is the initial Step -->
<table width="500" border="0" class=sbs><tr>
<td>Router Light Status</td>
<td width="70" align="center" class="tiny">Off<br><input type="checkbox" onclick="DoItAll(Off,'putthisin')"><img src=1x1.gif width=70 height=1></td>
<td width="70" align="center" class="tiny">Amber<Br><input type="checkbox" onclick="DoItAll(Amber,'stickthis')"><img src=1x1.gif width=70 height=1></td>
<td width="70" align="center" class="tiny">Green<Br><input type="checkbox" onclick="DoItAll(Green,'stickthis')"><img src=1x1.gif width=70 height=1></td>
</tr></table>
<!-- End initial Step -->
<!-- Further steps are document.written below -->


<!-- DO NOT TOUCH BELOW HERE-->
<script>
//This loops through the objects and document.writes them
for (var index = 0; index < STEPbySTEPfixes.length; index++)
{
var item = STEPbySTEPfixes[index];
document.write("<div class=\"sbsdiv\" id=" + item.name + " style=\"display:none\"><table border=0 class=\"sbs\" width=500><tr><td>" + item.description + "</td>")
{if (item.option1 == "") {document.write("")} else {
document.write("<td width=70 align=center class=\"tiny\">" + item.option1 + "<br><input type=checkbox onclick=\"DoItAll(" + item.option1 + "," + item.writethis + ")\"><img src=1x1.gif width=70 height=1></td>")
}}
{if (item.option2 == "") {document.write("")} else {
document.write("<td width=70 align=center class=\"tiny\">" + item.option2 + "<br><input type=checkbox onclick=\"DoItAll(" + item.option2 + "," + item.writethis + ")\"><img src=1x1.gif width=70 height=1></td>")
}}
{if (item.option3 == "") {document.write("")} else {
document.write("<td width=70 align=center class=\"tiny\">" + item.option3 + "<br><input type=checkbox onclick=\"DoItAll(" + item.option3 + "," + item.writethis + ")\"><img src=1x1.gif width=7 0 height=1></td>")
}}
document.write("</tr></table></div>")
}
</script>
<!-- DO NOT TOUCH ABOVE HERE -->

</td>
<td align="right">

<textarea cols="48" rows="26" name="messageBox" wrap="virtual" class="text">

</textarea>
<input type="button" value="Select All" onClick="javascript:this.form.messageBox.focus();this.form.messageBox.select();" class="button">  <input type="reset" value="Reset" class="button">
</form>


</td>
<td width="16"> </td></tr></table>


</body>
</html>



::edit::

Yeah, InI, I need to look at cross-browser issues... I'm kind of lucky, this is intended for an intra, so I can get away with it... but I shouldn't really be lazy.



[This message has been edited by sonicsnail (edited 09-30-2002).]

sonicsnail
Bipolar (III) Inmate

From: Scotland
Insane since: Jun 2001

posted posted 10-02-2002 16:24

Ok, so I'm stuck again :-)

I want the 'reset' button at the bottom of the page to 'hide' all of the layers...

I know I need to loop through the layer objects, and set their style property Display to 'none' - but I can't get the damn sytax right!

Pls help...

Pete

sonicsnail
Bipolar (III) Inmate

From: Scotland
Insane since: Jun 2001

posted posted 10-04-2002 14:49

why no replies?

InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 10-04-2002 19:12

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

sonicsnail
Bipolar (III) Inmate

From: Scotland
Insane since: Jun 2001

posted posted 10-06-2002 00:10

Thanks once again InI, and my apologies for the tetchyness (sp?) of my last post. Stressful day, stressful code (for me anyway!)

I think I've got this working.. you're advice was really useful. Though I replicated part of the existing code that relates to the "object" in place, and it seems to have worked.

Very pleased. Very tired. Very grateful.

Pete

code:
function HideThemAll() {
for (var index = 0; index < STEPbySTEPfixes.length; index++)
{
var item = STEPbySTEPfixes[index];
document.getElementsByTagName("div")[item.name].style.display = "none";

}
}

« BackwardsOnwards »

Show Forum Drop Down Menu