# Really Basic Syntax Question

**URL:** <https://forum.kirupa.com/t/really-basic-syntax-question/222566>\
**Category:** web dev\
**Created:** [April 14, 2007, 10:45pm UTC](https://forum.kirupa.com/t/really-basic-syntax-question/222566 "2007-04-14T22:45:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shard](https://avatars.discourse-cdn.com/v4/letter/s/c5a1d2/32.png) [@Shard](https://forum.kirupa.com/u/Shard)\
**Post date:** [April 14, 2007, 10:45pm UTC](https://forum.kirupa.com/t/really-basic-syntax-question/222566/1 "2007-04-14T22:45:07Z")

</div>

Hi all 🙂  
Here’s a really simple question that I can’t believe has be stumped - lol  
I need to reference a form element using two variable names to represent the actual form element names and the syntax of that request is driving me insane. Imagine we have a form called “theform” which has a select list called “cities” and the 3rd option is “New York”. If I have stored the index number of “New York” (2) in a variable called “lookingat”, and the name of the select box “Cities” in another variable called “lookingwhere”, then what would the request syntax be?

document.theform.lookingwhere.options[lookingat].selected = true;

The problem is the lookingwhere inclusion in this statement, it automatically tries to find a form element called “lookingwhere” cause the syntax is wrong. I’ve tried surrounding it with brackets, quotes, using an eval and then splitting the reuest etc but to no avail.

I am sure its a REALLY simple matter of an extra dot or comma etc. PLEASE HELP.
