/    Sign up×
Community /Pin to ProfileBookmark

Brain Cramp – Separating One Value Into Two Values

I can’t believe that I can’t figure this one out, but here it goes:

How do I split the original value into two values by using the Substring or another method without using an array?

Example:
Original value = 12.1
ValueA = 12
ValueB = 1

Session(“ValueA”) = Original_Value.Substring(0,”.”);
Session(“ValueB”) = Original_Value.Substring(“.”);

I know that the above example is wrong, but I can’t remember how to do this. Any help would be great. Thanks.

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@gphJan 24.2006 — myvar=myvar.toString().split('.');

alert(myvar[0]+'n'+myvar[1]);
Copy linkTweet thisAlerts:
@kwilliamsauthorJan 25.2006 — myvar=myvar.toString().split('.');

alert(myvar[0]+'n'+myvar[1]);[/QUOTE]


Thanks for the great answer. I was able to create a solution from your suggestion, like this:

[B]CODE:[/B]

//Value Split

var OldValue = Session("Value");

var NewValue = OldValue.toString().split(".");

Session("ValueA") = NewValue[0];

Session("ValueB") = NewValue[1];

//TEST

Response.Write("Original Value: " + Session("Value"));

Response.Write("<br />");

Response.Write("ValueA: " + Session("ValueA"));

Response.Write("<br />");

Response.Write("ValueB: " + Session("ValueB"));

[B]RESULT:[/B]

Original Value: 43.1

ValueA: 43

ValueB: 1

Thanks so much for your help gph?
×

Success!

Help @kwilliams spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.4,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...