Thanks both of you. I am starting to understand a little. I will do the tutorials to learn more. I will post more if i have any question. Thanks alot guys.
Irwin
Printable View
Thanks both of you. I am starting to understand a little. I will do the tutorials to learn more. I will post more if i have any question. Thanks alot guys.
Irwin
I am now doing the multiselect. I can now multiselect and get the values but I do not know how to spilt the values. This is the code I am using, I understand what it does but I do not know how to seperate the values.
Irwin
Either I'am going blind or you didn't post your code.Quote:
Originally Posted by lchi
As for seperating the values in a multiselect that is explained in the page I posted a link to back in comment #6.
You might also want to take a look at some string functions
http://www.w3schools.com/js/js_obj_string.asp
Opps looks like I forgot haha. I was in a hurry yesterday.
Here are the codes.
function loopSelected()
{
var BATfileObj = document.getElementById('BATfile');
var selectedArray = new Array();
var selObj = document.getElementById('select1');
var i;
var count = 0;
for (i=0; i<selObj.options.length; i++) {
if (selObj.options[i].selected) {
selectedArray[count] = selObj.options[i].value;
count++;
}
}
BATfileObj.value = selectedArray;
}
I got it from the codes from the tutorial you give me. The values it gives out are in this form value1,value2,value3,value4. I want to seperate the values. How do you do it.
Irwin
Ehh, you already got the values seperated inside the 'for' loop on this lineQuote:
Originally Posted by lchi
I assume what you meant to say, was that you want each of values the values on a line by itself, in the text area.Code:selectedArray[count] = selObj.options[i].value;
Again You obviouly haven't been paying any attention to what I have been telling you about concatenating strings.
To get the select values, each on a line by itself, you could just replace the above line with
Although this is bit of a misnomer on my part, since selectArray is now a string rather than a Array of strings.Code:selectedArray += selObj.options[i].value + "\n";
And once again please read some more tutorials and try to put a lot more work into your problems before asking for help. As far as I'am concerned you are rapidly becoming the boy how cried wolf.
Thanks. What I don't understand is the array part I thought that
for (i=0; i<selObj.options.length; i++) {
if (selObj.options[i].selected) {
selectedArray[count] = selObj.options[i].value;
count++;
this part just all the values and put it together I was not sure so I ask.
Sorry for the problem I cause. But I thank you for teaching me alot.
But one more question what is the count and count++ for?
Thanks
Irwin
Again I must strongly suggest that you go read some tutorials, the ++ operator is explained at http://www.w3schools.com/js/js_operators.aspQuote:
Originally Posted by lchi
You are building an array of the selected options from all the options, Every time you find a selected option you insert the value into result array at position count. And increment the count variable so that the next selected option will be inserted at the next position in the result array.
Thank you I understand what you mean. I know what a ++ means I was just wondering what the count is for as there is var i for the values. So the count is for selected values. Thanks alot.
Irwin