How to add combo box on webpage to assign value from table field?

John

Member
I'm creating as form in Webspeed using AJAX. There is a logical field added on this.

If I am adding below text box to accept Yes or No like below then this is working fine.
<td><input type="text" name="activ" class="text_box" id="fld_active" value=`if available(pt_mstr) then string(pt_active) else 'Yes'`></td>
Now I want to change this from text box to combo box. Though below code is working ok but I see bit awkward.
Could someone verify if this approach is ok?

<td>
<select id="fld_xxac_active" value=`if available(xxac_mstr) then string(xxac_active) else 'no'`>
<option value="Yes" selected>Yes </option>
<option value="No" >No </option>
</select>
</td>
 
I'm creating as form in Webspeed using AJAX. There is a logical field added on this.

If I am adding below text box to accept Yes or No like below then this is working fine.
<td><input type="text" name="activ" class="text_box" id="fld_active" value=`if available(pt_mstr) then string(pt_active) else 'Yes'`></td>
Now I want to change this from text box to combo box. Though below code is working ok but I see bit awkward.
Could someone verify if this approach is ok?

<td>
<select id="fld_xxac_active" value=`if available(xxac_mstr) then string(xxac_active) else 'no'`>
<option value="Yes" selected>Yes </option>
<option value="No" >No </option>
</select>
</td>
Wrong, on "Select" the value passed is on the "option" not in the Select itself.

First, I would add xxac_active on a mem variable; let'say "isactive": isactive=if available(xxac_mstr) then xxac_active else false.
After that:
<td>
<select id="fld_xxac_active">
<option value="Yes" `(IF isactive THEN "selected" ELSE "")`>Yes </option>
<option value="No" `(IF NOT isactive THEN "selected" ELSE "")`>No </option>
</select>
</td>
 

John

Member
Thank you Marco for this reply.

I have one more query if you can help. I need to populate & display combobox from database table values and want to display on load of webpage.
Thanks in advance !
 

Cecil

19+ years progress programming and still learning.
Thank you Marco for this reply.

I have one more query if you can help. I need to populate & display combobox from database table values and want to display on load of webpage.
Thanks in advance !

Just to clear something up. You are using AJAX with WebSpeed. So do you want webspeed to generate the selection list (combo box) with all it's options or using AJAX have the Client side populate the Combo-box with options and set the select the desired value? If you are wanting the latter, what javascript library are you using i.e. JQuery, DoJo etc?


Traditional WebSpeed:

Code:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<HTML>
<HEAD>
<META NAME="AUTHOR" CONTENT="Your Name">
<TITLE>WebSpeed Script</TITLE>
<SCRIPT LANGUAGE="SpeedScript">
/* Create an unnamed pool to store all the widgets created by this procedure.
   This is a good default which assures that this procedure's triggers and
   internal procedures will execute in this procedure's storage, and that
   proper cleanup will occur on deletion of the procedure. */
CREATE WIDGET-POOL.
</SCRIPT>
</HEAD>

<BODY>
<SCRIPT LANGUAGE="SpeedScript">
  /*------------------------------------------------------------------
    File:
    Description:
    Created:
  -------------------------------------------------------------------*/
</SCRIPT>


<select>

        <SCRIPT LANGUAGE="SpeedScript">
                FOR EACH CUSTOMER NO-lock:
        </SCRIPT>

               <option value="`Customer.CustomerNumber`" `(IF isactive THEN "selected" ELSE "")`>`Customer.CustomerName` </option>

        <SCRIPT LANGUAGE="SpeedScript">
                END.
        </SCRIPT>

<select>

</BODY>
</HTML>
 
Last edited:
Top