Forum

HomeHomeCoreCoreSamples and oth...Samples and oth...COALESCE Drop down list with default SampleCOALESCE Drop down list with default Sample
Previous
 
Next
New Post
5/13/2010 12:17 AM
 

I struggled with COALESCE over what turned out to be a simple issue so I thought I would share my experience and hopefully save someone else a bit of time. What follows is an example of a drop down list using subquery and coalesce, where the drop down list has a default (other than the first option).

Here is the scenario: I have a form with a drop down list which allows the end user to select a (US) state. However I wanted the list to default to the end user’s home state, in this case “WA” (#48 in the list).

The bugger was of course, coalesce. The syntax I used was : [COALESCE,USStateID,AddrData,"48",Text,,] What held me up was the second of the two trailing commas. I’m almost embarrassed to say it, but it was a good hour before I figured it out.

The full element is as follows:

<select>
{SUBQUERY,
name="statelookup",
query="SELECT USStateID,Abbr FROM USStates",
format="<option value='\[USStateID\]'>\[Abbr\]</option>",
selectedformat="<option value='\[USStateID\]' selected=\"selected\">\[Abbr\]</option>",
selectedfield="USStateID",
selecteditems="[COALESCE,USStateID,AddrData,"48",Text,,]",
useCache="False"}
</select>

Where USStates is a table, USStateID is the ID column (and index), and Abbr is the column containing state abbreviations.



Best regards,
Robert
New Post
5/18/2010 6:52 AM
 

I am using something similar for a drop down but I am trying to insert both the ID and Abbr into my main table. My insert query is not working at all. Do you happen to have an example of an insert query that will add both the ID and Abbr?

New Post
5/20/2010 9:46 AM
 

I assume you are using a “Variable” Action to capture the ID, which in turn is used in your Query Template.

If so, then one approach would be to create a hidden HTML input field and populate the value via javascript in the onchange event of the drop down. When the form is posted to OWS you would use another Variable Action to capture the Abbr.



Best regards,
Robert
Previous
 
Next
HomeHomeCoreCoreSamples and oth...Samples and oth...COALESCE Drop down list with default SampleCOALESCE Drop down list with default Sample


 

New York, NY • Baltimore, MD • Vienna, VA • St. Louis, MO • Seatle, WA • 410.327.0007 • info@R2Integrated.com

Bookmark & Share Bookmark and Share