<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>'cutting var' Thread RSS Feed</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest posts from the thread 'cutting var' posted on the 'JavaScript' forum at Programmer's Heaven.</description>
    <language>en</language>
    <copyright>Copyright 2013 Programmers Heaven</copyright>
    <pubDate>Sat, 18 May 2013 03:16:58 -0700</pubDate>
    <lastBuildDate>Sat, 18 May 2013 03:16:58 -0700</lastBuildDate>
    <generator>Argotic Syndication Framework 2007.3.0.1, http://www.codeplex.com/Argotic</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>360</ttl>
    <image>
      <url>http://www.programmersheaven.com/images/ph.gif</url>
      <title>Programmers Heaven</title>
      <link>http://www.programmersheaven.com/</link>
      <width>88</width>
      <height>31</height>
    </image>
    <item>
      <title>cutting var</title>
      <link>http://www.programmersheaven.com/mb/java-script/120023/120023/cutting-var/</link>
      <description>I know nothing of Java Script. I am customizing a program that allows users to modify java script in the program. I need to know if there is a way to cut the firt character in a varible I.E. if my varible was "0987878" how can I cut the "0"? Any help would be greatly appreciated.&lt;br /&gt;
&lt;br /&gt;
Roger&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/java-script/120023/120023/cutting-var/</guid>
      <pubDate>Wed, 05 Jun 2002 08:29:32 -0700</pubDate>
      <category>JavaScript</category>
    </item>
    <item>
      <title>Re: cutting var</title>
      <link>http://www.programmersheaven.com/mb/java-script/120023/120314/re-cutting-var/#120314</link>
      <description>: I know nothing of Java Script. I am customizing a program that allows users to modify java script in the program. I need to know if there is a way to cut the firt character in a varible I.E. if my varible was "0987878" how can I cut the "0"? Any help would be greatly appreciated.&lt;br /&gt;
: &lt;br /&gt;
: Roger&lt;br /&gt;
: &lt;br /&gt;
&lt;br /&gt;
Hi there,&lt;br /&gt;
&lt;br /&gt;
Try this...&lt;br /&gt;
&lt;br /&gt;
var aString = "0987878";&lt;br /&gt;
var newString = "";&lt;br /&gt;
&lt;br /&gt;
newString = aString.substring(1, aString.length);&lt;br /&gt;
&lt;br /&gt;
This will remove the first character of anything inside aString and store the result in newString.&lt;br /&gt;
&lt;br /&gt;
You could go one better and do this...&lt;br /&gt;
&lt;br /&gt;
var aString = "0987878";&lt;br /&gt;
&lt;br /&gt;
aString = aString.substring(1, aString.length);&lt;br /&gt;
&lt;br /&gt;
This will overwrite the value of aString with the original value minus the first character!&lt;br /&gt;
&lt;br /&gt;
Hope this helps!&lt;br /&gt;
Bradley q:)&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/java-script/120023/120314/re-cutting-var/#120314</guid>
      <pubDate>Thu, 06 Jun 2002 23:18:40 -0700</pubDate>
      <category>JavaScript</category>
    </item>
    <item>
      <title>Re: cutting var</title>
      <link>http://www.programmersheaven.com/mb/java-script/120023/120365/re-cutting-var/#120365</link>
      <description>&lt;br /&gt;
Thanks for your responce... I found out only after I had posted that message the first character only needs to be stripped when it is zero, and sometimes there are more than one "0". I eventullay came to the following code which uses the same substring function. Although I suppose I could clean it up a bit and remove some varibles.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
       if (strTemp.charAt(0) == "0"){
        	var newTerm
          	while (strTemp.charAt(0) == "0") {
          		newTerm = strTemp.substring(1, strTemp.length)
          		strTemp = newTerm;
	}
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
~rlc&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/java-script/120023/120365/re-cutting-var/#120365</guid>
      <pubDate>Fri, 07 Jun 2002 06:16:30 -0700</pubDate>
      <category>JavaScript</category>
    </item>
    <item>
      <title>Re: cutting var</title>
      <link>http://www.programmersheaven.com/mb/java-script/120023/120398/re-cutting-var/#120398</link>
      <description>Yes:&lt;br /&gt;
&lt;br /&gt;
The first two lines of code are not necessary. What you do now is: first check if the first character is a 0 and then loop checking if the first character is a zero. &lt;br /&gt;
Also, you don't need to store it in newTerm first. See the changes:&lt;br /&gt;
&lt;br /&gt;
 &lt;pre class="sourcecode"&gt;
  //      if (strTemp.charAt(0) == "0"){   &lt;span style="color: Green;"&gt; These two lines are 
&lt;/span&gt;  //       	var newTerm                 &lt;span style="color: Green;"&gt; obsolete &lt;/span&gt;
           	while (strTemp.charAt(0) == "0") {
  // &lt;span style="color: Green;"&gt; Notice the change of newTerm to strTemp  &lt;/span&gt;
           		strTemp = strTemp.substring(1, strTemp.length)
  //         		strTemp = newTerm; &lt;span style="color: Green;"&gt;You can delete this too then &lt;/span&gt;
 	}
 &lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
Of course, to make it even better, you could change the name of strTemp to a more useful name like phonenumber&lt;br /&gt;
&lt;br /&gt;
: &lt;br /&gt;
: Thanks for your responce... I found out only after I had posted that message the first character only needs to be stripped when it is zero, and sometimes there are more than one "0". I eventullay came to the following code which uses the same substring function. Although I suppose I could clean it up a bit and remove some varibles.&lt;br /&gt;
: &lt;br /&gt;
: &lt;pre class="sourcecode"&gt;
:        if (strTemp.charAt(0) == "0"){
:         	var newTerm
:           	while (strTemp.charAt(0) == "0") {
:           		newTerm = strTemp.substring(1, strTemp.length)
:           		strTemp = newTerm;
: 	}
: &lt;/pre&gt;&lt;br /&gt;
: &lt;br /&gt;
: ~rlc&lt;br /&gt;
: &lt;br /&gt;
: &lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/java-script/120023/120398/re-cutting-var/#120398</guid>
      <pubDate>Fri, 07 Jun 2002 08:23:08 -0700</pubDate>
      <category>JavaScript</category>
    </item>
    <item>
      <title>Re: cutting var</title>
      <link>http://www.programmersheaven.com/mb/java-script/120023/120539/re-cutting-var/#120539</link>
      <description>Thanks, i did remove the extra var already. However, I couldn't remove the "if" loop. When I just used a "While" loop the script always checks the condition after it has run through the loop once. I.E. it would delete the first character no matter what, then look to see if "0" was first. The "if" loop checks before it runs and stopped this problem for me. I didn't see a way to do this with one loop, but if there is let me know.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
~rlc&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
: Yes:&lt;br /&gt;
: &lt;br /&gt;
: The first two lines of code are not necessary. What you do now is: first check if the first character is a 0 and then loop checking if the first character is a zero. &lt;br /&gt;
: Also, you don't need to store it in newTerm first. See the changes:&lt;br /&gt;
: &lt;br /&gt;
:  &lt;pre class="sourcecode"&gt;
:   //      if (strTemp.charAt(0) == "0"){   &lt;span style="color: Green;"&gt; These two lines are 
: &lt;/span&gt;  //       	var newTerm                 &lt;span style="color: Green;"&gt; obsolete &lt;/span&gt;
:            	while (strTemp.charAt(0) == "0") {
:   // &lt;span style="color: Green;"&gt; Notice the change of newTerm to strTemp  &lt;/span&gt;
:            		strTemp = strTemp.substring(1, strTemp.length)
:   //         		strTemp = newTerm; &lt;span style="color: Green;"&gt;You can delete this too then &lt;/span&gt;
:  	}
:  &lt;/pre&gt;&lt;br /&gt;
: &lt;br /&gt;
: Of course, to make it even better, you could change the name of strTemp to a more useful name like phonenumber&lt;br /&gt;
: &lt;br /&gt;
: : &lt;br /&gt;
: : Thanks for your responce... I found out only after I had posted that message the first character only needs to be stripped when it is zero, and sometimes there are more than one "0". I eventullay came to the following code which uses the same substring function. Although I suppose I could clean it up a bit and remove some varibles.&lt;br /&gt;
: : &lt;br /&gt;
: : &lt;pre class="sourcecode"&gt;
: :        if (strTemp.charAt(0) == "0"){
: :         	var newTerm
: :           	while (strTemp.charAt(0) == "0") {
: :           		newTerm = strTemp.substring(1, strTemp.length)
: :           		strTemp = newTerm;
: : 	}
: : &lt;/pre&gt;&lt;br /&gt;
: : &lt;br /&gt;
: : ~rlc&lt;br /&gt;
: : &lt;br /&gt;
: : &lt;br /&gt;
: &lt;br /&gt;
: &lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/java-script/120023/120539/re-cutting-var/#120539</guid>
      <pubDate>Sat, 08 Jun 2002 07:06:07 -0700</pubDate>
      <category>JavaScript</category>
    </item>
    <item>
      <title>Re: cutting var</title>
      <link>http://www.programmersheaven.com/mb/java-script/120023/120544/re-cutting-var/#120544</link>
      <description>&lt;strong&gt;&lt;span style="color: Red;"&gt;This message was edited by the compuchip at  2002-6-8 8:13:1&lt;/span&gt;&lt;/strong&gt;&lt;hr /&gt;&lt;br /&gt;
Well, maybe it is a difference between our computers, but this code works with me&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
 while (strTemp.charAt(0) == "0") {
  strTemp = strTemp.substring(1, strTemp.length)
 }
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
You may be confused with the following use of while, which ALWAYS removes the first character, no matter what:&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
 do {
  strTemp = strTemp.substring(1, strTemp.length)
 } while (strTemp.charAt(0) == "0");
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
I thought this was the same on every computer, but I'd be glad if anyone could confirm that.&lt;br /&gt;
&lt;br /&gt;
(EDIT) &lt;br /&gt;
Addition: you don't need the {braces}, just like in C++. So you can even write&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
 while (strTemp.charAt(0) == "0") 
  strTemp = strTemp.substring(1, strTemp.length);
&lt;/pre&gt;&lt;br /&gt;
because the while-loop consists only of one statement.&lt;br /&gt;
&lt;br /&gt;
: Thanks, i did remove the extra var already. However, I couldn't remove the "if" loop. When I just used a "While" loop the script always checks the condition after it has run through the loop once. I.E. it would delete the first character no matter what, then look to see if "0" was first. The "if" loop checks before it runs and stopped this problem for me. I didn't see a way to do this with one loop, but if there is let me know.&lt;br /&gt;
: &lt;br /&gt;
: &lt;br /&gt;
: ~rlc&lt;br /&gt;
: &lt;br /&gt;
: &lt;br /&gt;
: &lt;br /&gt;
: : Yes:&lt;br /&gt;
: : &lt;br /&gt;
: : The first two lines of code are not necessary. What you do now is: first check if the first character is a 0 and then loop checking if the first character is a zero. &lt;br /&gt;
: : Also, you don't need to store it in newTerm first. See the changes:&lt;br /&gt;
: : &lt;br /&gt;
: :  &lt;pre class="sourcecode"&gt;
: :   //      if (strTemp.charAt(0) == "0"){   &lt;span style="color: Green;"&gt; These two lines are 
: : &lt;/span&gt;  //       	var newTerm                 &lt;span style="color: Green;"&gt; obsolete &lt;/span&gt;
: :            	while (strTemp.charAt(0) == "0") {
: :   // &lt;span style="color: Green;"&gt; Notice the change of newTerm to strTemp  &lt;/span&gt;
: :            		strTemp = strTemp.substring(1, strTemp.length)
: :   //         		strTemp = newTerm; &lt;span style="color: Green;"&gt;You can delete this too then &lt;/span&gt;
: :  	}
: :  &lt;/pre&gt;&lt;br /&gt;
: : &lt;br /&gt;
: : Of course, to make it even better, you could change the name of strTemp to a more useful name like phonenumber&lt;br /&gt;
: : &lt;br /&gt;
: : : &lt;br /&gt;
: : : Thanks for your responce... I found out only after I had posted that message the first character only needs to be stripped when it is zero, and sometimes there are more than one "0". I eventullay came to the following code which uses the same substring function. Although I suppose I could clean it up a bit and remove some varibles.&lt;br /&gt;
: : : &lt;br /&gt;
: : : &lt;pre class="sourcecode"&gt;
: : :        if (strTemp.charAt(0) == "0"){
: : :         	var newTerm
: : :           	while (strTemp.charAt(0) == "0") {
: : :           		newTerm = strTemp.substring(1, strTemp.length)
: : :           		strTemp = newTerm;
: : : 	}
: : : &lt;/pre&gt;&lt;br /&gt;
: : : &lt;br /&gt;
: : : ~rlc&lt;br /&gt;
: : : &lt;br /&gt;
: : : &lt;br /&gt;
: : &lt;br /&gt;
: : &lt;br /&gt;
: &lt;br /&gt;
: &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/java-script/120023/120544/re-cutting-var/#120544</guid>
      <pubDate>Sat, 08 Jun 2002 08:10:17 -0700</pubDate>
      <category>JavaScript</category>
    </item>
    <item>
      <title>Re: cutting var</title>
      <link>http://www.programmersheaven.com/mb/java-script/120023/121122/re-cutting-var/#121122</link>
      <description>Hi all,&lt;br /&gt;
&lt;br /&gt;
Yep I've just confirmed that in IE6 on WinXP the code that compuchip suggested worked for me...&lt;br /&gt;
&lt;br /&gt;
I just wrote a quick simple page to show it in action for you...&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;

&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
&amp;lt;script language="JavaScript"&amp;gt;

function doIt() {
	var strTemp = document.a.strTemp.value;
	while (strTemp.charAt(0) == "0") {
		strTemp = strTemp.substring(1, strTemp.length)
	}
	document.a.strTemp.value = strTemp;
}

&amp;lt;/script&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
&amp;lt;form name="a"&amp;gt;
&amp;lt;input type="text" name="strTemp" onChange="doIt();"&amp;gt;
&amp;lt;/form&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;

&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
Cya&lt;br /&gt;
Bradley q:)&lt;br /&gt;
&lt;br /&gt;
: &lt;strong&gt;&lt;span style="color: Red;"&gt;This message was edited by the compuchip at  2002-6-8 8:13:1&lt;/span&gt;&lt;/strong&gt;&lt;hr /&gt;&lt;br /&gt;
: Well, maybe it is a difference between our computers, but this code works with me&lt;br /&gt;
: &lt;pre class="sourcecode"&gt;
:  while (strTemp.charAt(0) == "0") {
:   strTemp = strTemp.substring(1, strTemp.length)
:  }
: &lt;/pre&gt;&lt;br /&gt;
: &lt;br /&gt;
: You may be confused with the following use of while, which ALWAYS removes the first character, no matter what:&lt;br /&gt;
: &lt;pre class="sourcecode"&gt;
:  do {
:   strTemp = strTemp.substring(1, strTemp.length)
:  } while (strTemp.charAt(0) == "0");
: &lt;/pre&gt;&lt;br /&gt;
: &lt;br /&gt;
: I thought this was the same on every computer, but I'd be glad if anyone could confirm that.&lt;br /&gt;
: &lt;br /&gt;
: (EDIT) &lt;br /&gt;
: Addition: you don't need the {braces}, just like in C++. So you can even write&lt;br /&gt;
: &lt;pre class="sourcecode"&gt;
:  while (strTemp.charAt(0) == "0") 
:   strTemp = strTemp.substring(1, strTemp.length);
: &lt;/pre&gt;&lt;br /&gt;
: because the while-loop consists only of one statement.&lt;br /&gt;
: &lt;br /&gt;
: : Thanks, i did remove the extra var already. However, I couldn't remove the "if" loop. When I just used a "While" loop the script always checks the condition after it has run through the loop once. I.E. it would delete the first character no matter what, then look to see if "0" was first. The "if" loop checks before it runs and stopped this problem for me. I didn't see a way to do this with one loop, but if there is let me know.&lt;br /&gt;
: : &lt;br /&gt;
: : &lt;br /&gt;
: : ~rlc&lt;br /&gt;
: : &lt;br /&gt;
: : &lt;br /&gt;
: : &lt;br /&gt;
: : : Yes:&lt;br /&gt;
: : : &lt;br /&gt;
: : : The first two lines of code are not necessary. What you do now is: first check if the first character is a 0 and then loop checking if the first character is a zero. &lt;br /&gt;
: : : Also, you don't need to store it in newTerm first. See the changes:&lt;br /&gt;
: : : &lt;br /&gt;
: : :  &lt;pre class="sourcecode"&gt;
: : :   //      if (strTemp.charAt(0) == "0"){   &lt;span style="color: Green;"&gt; These two lines are 
: : : &lt;/span&gt;  //       	var newTerm                 &lt;span style="color: Green;"&gt; obsolete &lt;/span&gt;
: : :            	while (strTemp.charAt(0) == "0") {
: : :   // &lt;span style="color: Green;"&gt; Notice the change of newTerm to strTemp  &lt;/span&gt;
: : :            		strTemp = strTemp.substring(1, strTemp.length)
: : :   //         		strTemp = newTerm; &lt;span style="color: Green;"&gt;You can delete this too then &lt;/span&gt;
: : :  	}
: : :  &lt;/pre&gt;&lt;br /&gt;
: : : &lt;br /&gt;
: : : Of course, to make it even better, you could change the name of strTemp to a more useful name like phonenumber&lt;br /&gt;
: : : &lt;br /&gt;
: : : : &lt;br /&gt;
: : : : Thanks for your responce... I found out only after I had posted that message the first character only needs to be stripped when it is zero, and sometimes there are more than one "0". I eventullay came to the following code which uses the same substring function. Although I suppose I could clean it up a bit and remove some varibles.&lt;br /&gt;
: : : : &lt;br /&gt;
: : : : &lt;pre class="sourcecode"&gt;
: : : :        if (strTemp.charAt(0) == "0"){
: : : :         	var newTerm
: : : :           	while (strTemp.charAt(0) == "0") {
: : : :           		newTerm = strTemp.substring(1, strTemp.length)
: : : :           		strTemp = newTerm;
: : : : 	}
: : : : &lt;/pre&gt;&lt;br /&gt;
: : : : &lt;br /&gt;
: : : : ~rlc&lt;br /&gt;
: : : : &lt;br /&gt;
: : : : &lt;br /&gt;
: : : &lt;br /&gt;
: : : &lt;br /&gt;
: : &lt;br /&gt;
: : &lt;br /&gt;
: &lt;br /&gt;
: &lt;br /&gt;
: &lt;br /&gt;
: &lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/java-script/120023/121122/re-cutting-var/#121122</guid>
      <pubDate>Tue, 11 Jun 2002 17:42:15 -0700</pubDate>
      <category>JavaScript</category>
    </item>
  </channel>
</rss>