Drop-Down Select Lists Creator - Change default Option text

Place for comments, problems, questions, or any issue related to the JavaScript / PHP scripts from this site.
alfordfiles
Posts: 8

Drop-Down Select Lists Creator - Change default Option text

I use the Drop-Down Select Lists Creator, it is working great!
A simple question: Client wants first pulldown menu to have a different default option ...i.e.
First pulldown = ---Select Symptoms---
Second pulldown = ---Do You Also Have?---
Third pulldown = ---Do You Also Have?---
and so on...

Any ideas on how to accomplish this?

Admin Posts: 805
- If you want to change the default text for the 1st option in the first pulldown Select, call the obDSL[0].set1stOpTxt() method (AFTER calling the setObDSL() function).

obDSL[0].set1stOpTxt(resName, str);
- resName = the name of the resource with select lists data.
- str = a string with the text for the first Option of that set of Select-lists.

Example:

Code: Select all

<form action="#" method="post">
 <span id="slist_sl1" class="dslists"></span>
 <pre id="slist_opcnt" class="optioncnt"></pre>
</form>

<script type="text/javascript" src="setslists/getslists.js"></script>
<script>
setObDSL('file', 'slist');
obDSL[0].set1stOpTxt('slist', '--SomeText--');
</script>
There is also an example in the "test_set_1st_option_text.html" file in the archive with the script.
- Maybe you have to download again the script because I just added this feature (To be sure you get the last version, delete browser cache).

alfordfiles Posts: 8
I've downloaded and tried the new version. All the test html files work - but ONLY if using the files downloaded, NOT with any new menus I create :(

Anything new throws a JSON wrong format error; and mysql shows nothing at all.

The original version works great – but this change to the first Option does not work - guess it only works in the new version.

Admin Posts: 805
Not sure what the cause is. I tested the script with other new ".json" files created with the new version, and it works.
Post here the content of a ".json" file with the select-lists you created, so I can test.
Also, add the name of the ".json" file and the html and javascript code you made to use the script to get the select-lists data from that file.

alfordfiles Posts: 8
Okay and thank you for all your help
JSON files 1) slist; and 2) eyes2 (new) – both are identical
But - the HTML will read both JSON or mySQL just fine for slist
Switch to eyes2, I get error "Incorrect JSON format" and no list shows using either JSON or mySQL

Link to HTML pg: using "eyes2"
emg-infinite.com/health-portal/WebContent/html2-version/checkMySymptomsMale-test.html

Roll cursor over male image - HEAD >> EYES (this is the only one set up)
I am using iFrame (so long content scrolls) which contains the js code to get the select-lists: URL for the iFrame is:
emg-infinite.com/health-portal/WebContent/html2-version/symptoms-selector/eyes.html

JSON for eyes2:

Code: Select all

[{"0":[1,2],"1":[3,4,5,13],"2":[12],"3":[10,11],"4":[8,9],"5":[6,7]}, [{"value":"Root","content":"","parent":-1},{"value":"Flash Games","content":"","parent":0},{"value":"HTML5 Games","content":"","parent":0},{"value":"Adventure","content":"Address: \n <a href=\"https://coursesweb.net/games/adventure\">Adventure</a>","parent":1},{"value":"Logic-perspicacity","content":"Address: \n <a href=\"https://coursesweb.net/games/logic-perspicacity\">Logic-perspicacity</a>","parent":1},{"value":"Puzzle","content":"Address: \n <a href=\"https://coursesweb.net/games/puzzle\">Puzzle</a>","parent":1},{"value":"Match 3 Christmas","content":" <a href=\"https://coursesweb.net/games/match-3-christmas\">Match 3 Christmas</a>\n Swap the Christmas items to combine identical 3 items horizontally or vertically, make all the blocks brighten.","parent":5},{"value":"Farmscapes","content":"<a href=\"https://coursesweb.net/games/farmscapes\">Farmscapes</a>\n Accompany Joe in this holiday to his grandfather to restore his ranch, to make fresh veggies.","parent":5},{"value":"Tiny King","content":"<a href=\"https://coursesweb.net/games/tiny-king\">Tiny King</a>\n Enter into a funny fairy tale with a cute little king. Find the key and open the door to the next level","parent":4},{"value":"Clover Flower","content":"<a href=\"https://coursesweb.net/games/clover-flower\">Clover Flower</a>\n Bring water and sunlight to the clover flower to make it blossom and happy in this beautiful game.","parent":4},{"value":"Snail Bob 8 Island Story","content":"<a href=\"https://coursesweb.net/games/snail-bob-8-island-story\">Snail Bob 8 Island Story</a>\n The brave Snail Bob reached on a primitive island, help him go back home safe and happy.","parent":3},{"value":"Jungle Fun","content":"<a href=\"https://coursesweb.net/games/jungle-fun\">Jungle Fun</a>\n Jungle Boy is looking for hidden treasures and he has to find his way with the help of animal friends.","parent":3},{"value":"Light the Stars","content":"<a href=\"https://coursesweb.net/blog/light-the-stars-game\">Light the Stars</a>\n The game tells itself what it is about.","parent":2},{"value":"Test List","content":"<br/><h4>Possible Conditions</h4><br/>\n<table class=\"table table-striped\">\n  <tbody>\n    <tr>\n      <td>Sinusitis</td>\n    </tr>\n    <tr>\n      <td>Aneurysm in the Brain</td>\n    </tr>\n    <tr>\n      <td>Cluster Headaches</td>\n    </tr>\n    <tr>\n      <td>Eye Emergencies</td>\n    </tr>\n  </tbody>\n</table>\n","parent":1}]]

Admin Posts: 805
The problem is that you didn't study well the code and comments in the pages for test from the archive with the script: "The ID of the elements with: id="..._sl1" must begin with the name of the file for that select lists".

In your code, the "fileName" in the id="fileName_sl1" (and id="fileName_opcnt") must be replaced with the name of the resource with select-list data (eyes2).
So, in your case: id="eyes_sl1" (and id="eyes2_opcnt").
- The code should be:

Code: Select all

<form action="#">
<span id="eyes2_sl1" class="dslists"></span>
<div id="eyes2_opcnt" class="optioncnt"></div>
</form>
<script type="text/javascript" src="setslists/getslists.js"></script>
<script type="text/javascript">
setObDSL('file', 'eyes2');  // for a single set of Drop-Down Lists
// setObDSL('file', ['fileName1', 'fileName2', 'fileName3']);  // for multiple sets of Drop-Down Lists
obDSL[0].set1stOpTxt('eyes2', '---Select Primary Symptom---');
</script>

alfordfiles Posts: 8
OMG - I am an idiot! I apologize - doing too much at once caused me to miss the obvious. It is working like a dream now!

Thank you! Thank you!

- One more question...is there a limit to the number of sub-levels I can have? If so, is it possible to increase this limit?
I was able to add a 5th level, so it looks like there isn't a limit - just if you could confirm, that would be great!

Admin Posts: 805
There is Not a limit to the number of sub-levels for the Drop-down select lists.
I just tested the script with a set of select-lists with 10 sub-levels.

Similar Topics