Web Hosting Talk







View Full Version : Javascript (Simple Problem)


shockuk
04-17-2008, 08:05 AM
Hi all,

I'm a PHP developer who normally tries to avoid Javascript (just haven't had time to learn it tbh, but it's definately on the agenda), and have enountered a problem that might have an easy solution.

Basically, I have a script that returns a name of a currently selected image dd.obj.name and the X coordinate of the current image dd.obj.x

I also have a form with lots of fields which will show the X value of the selected image <form name="xdisplayform"><input type="text" name="X1"><input type="text" name="X2"> (etc...)

Now, I would access this like so: document.xdisplayform.X1.value = dd.obj.x

However, since the script returns the "current" name and X value, I would need something like:
document.xdisplayform.Xdd.obj.name.value = dd.obj.x

But I don't have a clue how to make the variable name out of another variable in Javascript.

Hope that made since and hope someone can help, been searching Google for ages but not quite sure what keywords to search for.

Thanks for your help :)

eviltechie
04-17-2008, 08:34 AM
I don't exactly understand what your mean or what you're trying to accomplish, but I do know how to assign variables.

JS variable assignment:
var myvar = "hello world";

JS String Concat:
myvar = "prepended info: " + myvar;

arkin
04-17-2008, 09:19 AM
shockuk: Use a framework, hell of a lot easier for us PHP developers to understand and you also pick up the JS as you go, now they come in neat 25Kb filesizes also. :]

shockuk
04-17-2008, 01:11 PM
Thanks,

Problem solved. Got around it by using a similiar script that outputs in a different way :)