homepage Welcome to WebmasterWorld Guest from 54.167.41.199
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
var choice
stevelibby




msg:3604285
 5:45 pm on Mar 18, 2008 (gmt 0)

when declaring a var can it have a space or + sign, if so how would you go about constructing this.

 

Fotiman




msg:3604345
 6:36 pm on Mar 18, 2008 (gmt 0)

No, JavaScript vars can not have spaces or plus signs in their names.

stevelibby




msg:3604350
 6:44 pm on Mar 18, 2008 (gmt 0)

great if only i new this 9 hours ago lol.
right
i have a script that takes a value from box1 and in javascript the var becomes that name hence the question with spaces/+sign other than an underscore do you have any ideas?.

fside




msg:3604386
 7:07 pm on Mar 18, 2008 (gmt 0)

Any number of ways to go. You're looking for a lookup table. That's sort of to what the 'object' design lends itself.

If it's more complicated than that, you could show here exactly what you're trying to do.

stevelibby




msg:3604482
 8:47 pm on Mar 18, 2008 (gmt 0)

this is the script:
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
var Alfa_Romeo = new Array("('Select model','',true,true)","('146')","('147')","('156')","('159')","('166')","('Brera')","('GT')","('GTV')","('Spider')","('Any')");var Aston_Martin = new Array("('Select model','',true,true)","('DB7')","('DB9')","('Vanquish')","('Vantage')","('Virage')","('Any')");var Audi = new Array("('Select model','',true,true)","('100')","('80')","('A2')","('A3')","('A4')","('A4 Avant')","('A4 Cabriolet')","('A6')","('A6 Avant')","('A8')","('Cabriolet')","('Convertible')","('Coupe')","('Q7')","('S3')","('S4')","('S8')","('TT Coupe')","('Any')");
function populatemodel(inForm,selected) {
var selectedArray = eval(selected);

while (selectedArray.length < inForm.model.options.length) {
inForm.model.options[(inForm.model.options.length - 1)] = null;
}
for (var i=0; i < selectedArray.length; i++) {
eval("inForm.model.options[i]=" + "new Option" + selectedArray[i]);
}

if (inForm.make.options[0].value == '') {
inForm.make.options[0]= null;
if ( navigator.appName == 'Netscape') {
if (parseInt(navigator.appVersion) < 4) {
window.history.go(0);
}
else {
if (navigator.platform == 'Win32' navigator.platform == 'Win16') {
window.history.go(0);
}
}
}
}
}

// End -->
</script>
i want the alfa romeo to be alfa+romeo in the url bar after submission and not alfa_romeo as it is now

MarkFilipak




msg:3605032
 8:45 am on Mar 19, 2008 (gmt 0)

Well, it's nearly impossible to know what you intend from the code you have listed.

Put this in your browser's location bar and hit the Enter key and you may get an idea.

javascript:alert("Alfa_Romeo".replace("_", "+"));

Edit: left out closing paren.

[edited by: MarkFilipak at 8:47 am (utc) on Mar. 19, 2008]

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved