Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-06-2009, 11:53 PM   PM User | #1
codingforumsun
New Coder

 
Join Date: Feb 2009
Posts: 11
Thanks: 2
Thanked 0 Times in 0 Posts
codingforumsun is an unknown quantity at this point
JavaScript Array And split().....

First_Name=David`Last_Name=Grover`Home_Phone=111-111-1111`Work_Phone=111-111-1111`Cell_Phone=111-111-1111`Street=720 Kennedy Rd`Apt=1007`City=Scarborough`Province=ON`Postal_Code=M1K 2B7`Intersection=Keedy Rd X Eglon`Equipment=Total Gym 1000, 10X24 Foot Room`Session_Week=2`Sessions_Purchased=0`Days_Time_Preferred=Mon:12:00 am,1:00 am`Sessions_Left=0`Height=5.8`Weight=190`Goals=`Injury=None`Inj_Date=1900-01-01`Precaution=None`Doc_Clearence=None`Special_Order=None`Other_Concern=None`Exer_Program=None`Curren t_Exer_Resist=None`Supplementary=None`Howlong=None`Flexibility=1/1`Musk_Power=2/2`Rel_Mus_Stren=3/3`Cardio=4/4`Wall_Sit=5/5`Co_Ordi=Average`Musk_Endur=7/7`Abs_Mus_Stren=8/8`Body_Compo=9/9`Push_Ups=10/10`Sit_Ups=6/6`Core=12/12`Body_Fat=6`Weight=190`Notes=None`Assess_Dt=2009-01-26


The above is the value of var str value, returned by Database. So I use below code to split and put the values back to the form. but it does not work.
The alert displays right value( Last_Name=Grover ), but if I try to open the comments of for loop OR s = nameVal[0].split("="); the function never called at all.... I am not bothered about switch function fo rnow. Can anybody help me. I am new to JavaScript. I try to reply asap for any query. thank you.


var nameVal = new Array();
nameVal = str.split("`");
var s = new Array();
//for( int i=0; i<nameVal.length; i++) {
// s = nameVal[0].spilt("=");
alert( nameVal[1] + " "+nameVal.length);

/*switch (s[0]) {
case "Province" : //document.forms.Province.selectedIndex = s[1];
break;
case "Session_Week" : //document.forms.Session_Week.selectedIndex = s[1];
break;
case "Sessions_Purchased" : //document.forms.Sessions_Purchased.selectedIndex = s[1];
break;
case "Days_Time_Preferred" : //document.forms.Province.selectedIndex = s[1];
break;
case "Height" : //document.forms.Height.selectedIndex = s[1];
break;
case "Weight" : //document.forms.Weight.selectedIndex = s[1];
break;
case "Howlong" : //document.forms.Howlong.selectedIndex = s[1];
break;
case "Co_Ordi" : //document.forms.Co_Ordi.selectedIndex = s[1];
break;
case "Sessions_Left" : //document.forms.Province.selectedIndex = s[1];
break;
case "Body_Fat" : //document.forms.Body_Fat.selectedIndex = s[1];
break;
default: document.getElementsByName(s[0])[0].value=s[1];
}*/
//}
codingforumsun is offline   Reply With Quote
Old 03-07-2009, 01:17 AM   PM User | #2
codingforumsun
New Coder

 
Join Date: Feb 2009
Posts: 11
Thanks: 2
Thanked 0 Times in 0 Posts
codingforumsun is an unknown quantity at this point
The whole code is in the following function, called when the fprm is loaded with onload event.

function init(str) {
....
....
.... all the code.
....
....
....

}
codingforumsun is offline   Reply With Quote
Old 03-07-2009, 02:42 AM   PM User | #3
codingforumsun
New Coder

 
Join Date: Feb 2009
Posts: 11
Thanks: 2
Thanked 0 Times in 0 Posts
codingforumsun is an unknown quantity at this point
Hi everyone,
replacing int in the for loop with var solved the problem. also the split works and the function is being called.

now trying for the switch case problem. if anyone has the idea of if case value can be string.... early response is appreciated. thank you. let u know if I am able to solve it.

bye
codingforumsun is offline   Reply With Quote
Old 03-08-2009, 03:09 AM   PM User | #4
codingforumsun
New Coder

 
Join Date: Feb 2009
Posts: 11
Thanks: 2
Thanked 0 Times in 0 Posts
codingforumsun is an unknown quantity at this point
Switch("asdf") {

case "asdf" :

break;

}

the switch case also works fine
codingforumsun is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:21 AM.


Advertisement
Log in to turn off these ads.