Web Connection
HTMLDROPDOWN Value
Gravatar is a globally recognized avatar based on your email address. HTMLDROPDOWN Value
  Steve
  All
  Nov 20, 2025 @ 09:00am

Hi,
I am using the following code to select a customer on a form. It's working, it captures the Customer_ID and displays the Customer Name in the HTMLDROPDOWN control. When a customer selection is made, how can I also capture the Last_Name + First_Name value and plug it into another field on the same form? Like an OnClick() function that sets the Customer_Name field = Last_Name + First_Name?

<%= HtmlDropDown("Customer_ID",poRO.Customer_ID,"tCustomers","Customer_ID","Last_Name + [(] + First_Name + [)]",[class="form-control"],"--- Select a Customer","") %>

TIA,
Steve

Gravatar is a globally recognized avatar based on your email address. re: HTMLDROPDOWN Value
  Rick Strahl
  Steve
  Nov 20, 2025 @ 09:33am

You can't directly capture anything but the Value from an Html Text control in a POST operation.

However, you can do this with JavaScript as you pointed out. If you want to use JavaScript you can do the following:

  • Capture the onchange event on the combo
  • Capture whatever value you need to catch by looking at the ComboBox Html (ie. $("#comboBox>option[value='<selectedValue>']").text())
  • Write the value into a hidden form variable ie. <input type="hidden" value="captured text" />

You can get the captured text with something like this:

// Grab the selected value
var value = $("#Forum").val();

// Get the prompt text
var selectedText = $("#Forum>option[value='" + value + "']").text()

// Assign to a hidden variable that posts back
$("#hiddenCaption").val(selectedText)

However, I'd advise against that - while that works it's pretty messy and can have weird side effects if there are certain characters in the label string.

You should be able to do the co-relation on the server where the prompt originated in the first place and capture it there.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: HTMLDROPDOWN Value
  Steve
  Rick Strahl
  Nov 21, 2025 @ 04:35am

Thanks Rick! I took your advice and captured the info on the backend. It was easy and worked out better that way.

Steve

© 1996-2026