|
|
|
|
![]() ![]() |
Feb 4 2008, 06:50 AM
Post
#1
|
|
|
Newbie [ Level 2 ] Group: Members Posts: 23 Joined: 29-October 06 Member No.: 16,848 |
hi all,
I am facing problem in my javascript, any kind of help would be apreciated CODE function basicFiles(){ //var Z = ""; for (i = 0; i < document.Form.regionlist.options.length; i++) { var x = document.Form.regionlist.options[i].value; var y = document.Form.regionlist.options[i].text; var Z = "regions" + "[" + x + "]" + " = " + y + ", "; alert(Z); } } this works well but the following returns only errors CODE function basicFiles(){ //var Z = ""; for (i = 0; i < document.Form.regionlist.options.length; i++) { var x = document.Form.regionlist.options[i].value; var y = document.Form.regionlist.options[i].text; var Z = "regions" + "[" + x + "]" + " = " + y + ", "; document,write(Z); } window.close(); } thanks sherif This post has been edited by pyost: Feb 4 2008, 03:07 PM |
|
|
|
Feb 4 2008, 09:46 AM
Post
#2
|
|
|
Way Out Of Control - You need a life :) Group: [MODERATOR] Posts: 2,045 Joined: 16-August 05 Member No.: 7,896 |
I just made a slight change to your topic title in order to make it more specific to your problems.
|
|
|
|
Feb 8 2008, 12:56 AM
Post
#3
|
|
|
Super Member Group: [HOSTED] Posts: 763 Joined: 8-April 06 From: Lima - Peru Member No.: 12,579 |
In your second function you have a typo in document,write(Z); simply replace it with the following code:
CODE document.write(Z); But, when you executes this function you got an error and only works one time, so if your intention is to concatenate all the elements (values and texts) of the select in one string and then write it to the document -your Z variable- change your function to: CODE function basicFiles1() { var Z = new String(""); for (i = 0; i < document.Form.regionlist.options.length; i++) { var x = document.Form.regionlist.options[i].value; var y = document.Form.regionlist.options[i].text; Z = Z + "regions" + "[" + x + "]" + " = " + y + ", "; } Z = Z.substr(0,(Z.length-2)); document.write(Z); //window.close(); } Hope it helps and is what you need. Best regards, |
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 14th October 2008 - 03:45 AM |