I really think that is your best approach.  The time it takes JS to loop
over an array is nothing compared to a page request to the server.  Just
make sure you jsstringformat() any values going into the array.  

~Brad

-----Original Message-----
From: Scott Stewart [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, January 10, 2006 5:01 PM
To: CF-Talk
Subject: RE: I don't know if this is even possible

I've been looking at populating a javascript array and passing the array
values around..

Thanks

sas

Scott A. Stewart
ColdFusion Developer
 
GNSI
11820 Parklawn Dr
Rockville, MD 20852
(301) 770-9610  

-----Original Message-----
From: Brad Wood [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, January 10, 2006 5:58 PM
To: CF-Talk
Subject: RE: I don't know if this is even possible

Once again, you could do hidden iframe refresh trick here to set the
values of the fields.  

I think a good question to ask yourself is, do you really need to hit
the database for this, or will you know all the possible options right
up front.  

I don't know your exact application here, but I assume you have some
sort of display value and identifier you want to save based on the
selection in the drop down box.  If possible, I would populate the drop
down with a query which also contains the other values you would need
for each row should it be chosen.  (As long as that can be determined up
front).  

Now, you can do a couple different things.  You can build a JavaScript
array when the page loads which stores the options.  Onchange of the
drop down go to that array index to find what values you need to copy
into the text box and hidden fields. 
Also, I am not sure about other browsers, but IE will let you make up
attributes to HTML tags and reference them as element.attribute_name

For instance:
<select name="test_select" id="test_select "
onChange="do_something(this);">
        <option value="val1"
other_value_i_need_for_later="foo">me</option>
        <option value="val2"
other_value_i_need_for_later="bar">you</option>
</select>

Now let's say you choose the second option in the drop down

Function do_something(el)
{
        var that_other_value_i_needed = el.options[el.selectedIndex].
other_value_i_need_for_later;

document.getElementById('text_field_id').value =
that_other_value_i_needed;

}

I don't know if this is anywhere close to what you want, but it is my
two cents  :)  It sounds like there are probably lots of ways to do what
you want, just remember-- why go back to the database, if you can get it
to begin with.

~Brad


I have a text field and a hidden field that I want to populate based on
a
dropdown. Here's the trick, once the value of the dropdown is passed, I
want
the Hidden field and the text field to be based on queried values.






~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:229106
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to