Create simple multiple option list which displays predefined

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

ianpow
Forum Newbie
Posts: 6
Joined: Thu Sep 17, 2009 7:51 am

Re: Create simple multiple option list which displays predefined

Post by ianpow »

Nope, no error message and nothing else on screen. You click the button and nothing happens, nothing at all. Not even the yellow bar asking to allow scripts to run etc....... :banghead:
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: Create simple multiple option list which displays predefined

Post by jackpf »

Hmm...I'm at college atm. I'll check it out when I get home though.
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: Create simple multiple option list which displays predefined

Post by jackpf »

Omg...that was so stupid. <span style='color:blue' title='I&#39;m naughty, are you naughty?'>smurf</span> IE. There was an error message btw. Down in the left hand corner, that yellow warning symbol...

Apparently it doesn't like commas at the end of structs. For example:

Code: Select all

var foo = {    a: 'someproprty',    b: 'anotherone', //this comma is not allowed for some reason};
So yeah, here's the fixed code.

Code: Select all

<script>    var display = {        text: {            a: 'you selected a',            b: 'you selected b',            c: 'you selected c'        },        options: new Array(),        update: function()        {            var options = document.forms['formid'].selectName.options;                       this.options = new Array();                       for(var i = 0; i < options.length; i++)            {                if(options[i].selected)                {                    this.options[this.options.length] = this.text[options[i].value];                }            }                       var _display = document.getElementById('display');                       _display.innerHTML = '';                       for(i = 0; i < this.options.length; i++)            {                _display.innerHTML += this.options[i]+'<br />';            }        }    }</script> <form id="formid">    <select name="selectName" multiple="true">        <option value="a">a</option>        <option value="b">b</option>        <option value="c">c</option>    </select>       <input type="button" onclick="display.update();" value="blah" /></form> <div id="display"></div>
ianpow
Forum Newbie
Posts: 6
Joined: Thu Sep 17, 2009 7:51 am

Re: Create simple multiple option list which displays predefined

Post by ianpow »

Jack, pure genius! I made the changes you recommended and its working perfectly. Also used the wc3 validator to sort out some other cross browser issues and now it rocks!

Post your email address and i will connect so I can send you out some goody bag from the office -same goes for you Ollie.

btw, if you do this kind of thing at college then I can send you details of the full project this is part of, ppt's etc so you can show real world commercial applications of your work (we operate in over 50 countries wordwide) As a forum we have created something, which although relatively simple on the surface, will make a significant difference to the way a major corporate project delivers and the effectiveness with which over 1500 sales reps will execute new company strategy. And best of all - this was only done in only 3 days! :P
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: Create simple multiple option list which displays predefined

Post by jackpf »

Lool..internet goodies...I'm sceptical :P But there should be an "envelope" icon next to my username you can use to email me.

Nah, I don't learn this stuff at college. I learned C++, PHP & javascript in my spare time. At college I learn Delhpi :/ Only cause they make me though.
As a forum we have created something, which although relatively simple on the surface, will make a significant difference to the way a major corporate project delivers and the effectiveness with which over 1500 sales reps will execute new company strategy. And best of all - this was only done in only 3 days!
Glad I could help :)
Post Reply