it01y2 0 Report post Posted November 17, 2006 how do you delete the contents of a variable in javascript? Any ideas? Share this post Link to post Share on other sites
electriic ink 1 Report post Posted November 17, 2006 This is how I would do it. There might be a proper function that does it but this method works perfectly well. <script type="text/javascript">// Set variablecolour = "blue";// Delete its contentscolour ="";</script> Share this post Link to post Share on other sites
it01y2 0 Report post Posted November 17, 2006 ok I have javascript in a loop and the variables for each loop is clashing.egfirst loopvar countdown = "2"first loopsecond loopvar countdown = "5"second loopIs there any way in javascript to do thisx=0first loopx++varcountown x = 1first loopsecond loopx++varcountown x = 5second loopthe x results the variable name to be listedvarcountown1varcountown2varcountown3varcountown4varcountown5so they dont clash is this possible? electriic ink? Share this post Link to post Share on other sites
electriic ink 1 Report post Posted November 17, 2006 I am fairy sure the answer is no. Someone else might be able to say though; I don't know lots about Javascript. Share this post Link to post Share on other sites
hype 0 Report post Posted November 18, 2006 I dont really understand what are you trying to do but its possible that you give each variable a different name so that they dont clash and product different values for different var.. Share this post Link to post Share on other sites
it01y2 0 Report post Posted November 18, 2006 I cant do that because the script is in a php loop Share this post Link to post Share on other sites
darran 0 Report post Posted November 20, 2006 Perhaps you could describe what you are trying to do so we can understand the logic you are trying to get behind by using 2 loops. I don't really understand why you are using 2 loops to do a countdown. Share this post Link to post Share on other sites
electron 0 Report post Posted November 25, 2006 If it is in a PHP loop you can still change the name of the Variables.I did not get the reason why cant you have different names for the variables.Also if you dont want them to clash put / insert them in a array and then check if the value exists or not in the array.If it does then do something and change the value that will now be inserted.If it does not then insert it making things unique. Share this post Link to post Share on other sites