Skip to main content
deleted 650 characters in body
Source Link
Duc Le
  • 3.8k
  • 2
  • 8
  • 28

YouI don't think you can putuse AMPscript blocks at the picklist form field to dopopulate the product code (storing in a lookup and processdifferent DE) based on a loop to prepopulateproduct the valuecustomer will select in the Smart Capture form due to this activity comes from the lookup data extension.

Althoughclient side while AMPscript is serverside and you may need to set up a bit forcan only interact with it on the lookup DEserver side.

For example, my lookup DE has the "Product" field and I need to use these values in this column for the form picklist field. I would putrecommend using an additional "Remark" field and fill it withstep to process the data. In this case, you can use SQL query to populate the corresponding product code to a default value "Get value"new data extension.

In the picklist field form, I would do likeput a sample code for this:

<div class="smartcapture-controls"><div class="sc-formfield-label"><label for="Product">Product</label></div>
<div class="sc-formfield-input">
 <select name="Product" id="Product" data-field-type="Text">
   
  <option value="" id="" selected="selected"></option>

%%[SELECT
    SET @data = LookupRows("MY LOOKUP DE", "Remark"a.Product, "Get value")
    IF RowCount(@data) > 0 THENb.ProducCode
        FOR @i = 1 TO RowCount(@data) DOFROM
            SET[Your @rowtarget =DE] Row(@data,as @i)a
            SET @Product=  Field(@row,INNER "Product")
]%%
JOIN
<option value="%%=v(@Product)=%%"[Your id="%%=v(@Product)=%%">%%=v(@Product)=%%</option>
lookup DE] as b
%%[NEXT @i]%%ON
       a.Product 
%%[ENDIF]%%

= </select>
</div>
</div>b.Product

You can even add your own picklist value to that picklist form field by adding other option tags after the %%[ENDIF]%% block

You can put AMPscript blocks at the picklist form field to do a lookup and process a loop to prepopulate the value from the lookup data extension.

Although you may need to set up a bit for the lookup DE.

For example, my lookup DE has the "Product" field and I need to use these values in this column for the form picklist field. I would put an additional "Remark" field and fill it with a default value "Get value".

In the picklist field form, I would do like this:

<div class="smartcapture-controls"><div class="sc-formfield-label"><label for="Product">Product</label></div>
<div class="sc-formfield-input">
 <select name="Product" id="Product" data-field-type="Text">
   
  <option value="" id="" selected="selected"></option>

%%[
    SET @data = LookupRows("MY LOOKUP DE", "Remark", "Get value")
    IF RowCount(@data) > 0 THEN
        FOR @i = 1 TO RowCount(@data) DO
            SET @row = Row(@data, @i)
            SET @Product=  Field(@row, "Product")
]%%

<option value="%%=v(@Product)=%%" id="%%=v(@Product)=%%">%%=v(@Product)=%%</option>
   
%%[NEXT @i]%%
        
%%[ENDIF]%%

 </select>
</div>
</div>

You can even add your own picklist value to that picklist form field by adding other option tags after the %%[ENDIF]%% block

I don't think you can use AMPscript to populate the product code (storing in a different DE) based on a product the customer will select in the Smart Capture form due to this activity comes from the client side while AMPscript is serverside and you can only interact with it on the server side.

I would recommend using an additional step to process the data. In this case, you can use SQL query to populate the corresponding product code to a new data extension.

I put a sample code for this:

SELECT
a.Product,
b.ProducCode
FROM
[Your target DE] as a
INNER JOIN
[Your lookup DE] as b
ON
a.Product = b.Product
Source Link
Duc Le
  • 3.8k
  • 2
  • 8
  • 28

You can put AMPscript blocks at the picklist form field to do a lookup and process a loop to prepopulate the value from the lookup data extension.

Although you may need to set up a bit for the lookup DE.

For example, my lookup DE has the "Product" field and I need to use these values in this column for the form picklist field. I would put an additional "Remark" field and fill it with a default value "Get value".

In the picklist field form, I would do like this:

<div class="smartcapture-controls"><div class="sc-formfield-label"><label for="Product">Product</label></div>
<div class="sc-formfield-input">
 <select name="Product" id="Product" data-field-type="Text">
   
  <option value="" id="" selected="selected"></option>

%%[
    SET @data = LookupRows("MY LOOKUP DE", "Remark", "Get value")
    IF RowCount(@data) > 0 THEN
        FOR @i = 1 TO RowCount(@data) DO
            SET @row = Row(@data, @i)
            SET @Product=  Field(@row, "Product")
]%%

<option value="%%=v(@Product)=%%" id="%%=v(@Product)=%%">%%=v(@Product)=%%</option>
   
%%[NEXT @i]%%
        
%%[ENDIF]%%

 </select>
</div>
</div>

You can even add your own picklist value to that picklist form field by adding other option tags after the %%[ENDIF]%% block