Computing.Net > Forums > Web Development > Indirect assignments in javascript

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to get for your free account now!

Indirect assignments in javascript

Reply to Message Icon

Name: jimg
Date: December 5, 2007 at 14:19:10 Pacific
OS: 2003 Server
CPU/Ram: 3g P4, 4gb
Manufacturer/Model: Asus
Comment:

I have a form text box that I need to load, but the name of the field is a variable (quan1, quan2, etc.). The following code results in a blank alert and the box remains empty. I think I've tried all the simpler combinations. Any suggestions?

function spcfnc(x,value) {
setVar('window.order.quan'+x,value)
alert(eval('window.order.quan'+x).value)
}
function setVar(y,z){
y.value = z;
}


Report Offensive Message For Removal

Sponsored Link
Ads by Google

Response Number 1
Name: Michael J (by mjdamato)
Date: December 6, 2007 at 14:34:10 Pacific
Reply:

This should work:

alert(window.order['quan'+x].value)

Although, I would think you should be using 'document' and not 'window'

Michael J


Report Offensive Follow Up For Removal
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Web Development Forum Home


Sponsored links

Ads by Google


Results for: Indirect assignments in javascript

Image index in javascript www.computing.net/answers/webdevel/image-index-in-javascript/3401.html

Font Changing Coding in Javascript www.computing.net/answers/webdevel/font-changing-coding-in-javascript/1778.html

Images in Javascript with http:// l www.computing.net/answers/webdevel/images-in-javascript-with-http-l/534.html