Developer forum

Forum » Development » Save custom field value from dropdownlist

Save custom field value from dropdownlist

Hasan H. Samanci
Reply

Hey all,

I have a custom state for products which the user should set with options from a dropdown. The field and values are set in DW.

The Frontend code for dropdown:

 <select>
                <option>Select a Value</option>
                <!--@LoopStart(ProductState.Options)-->
                <option value='<!--@ProductState.Option.Value-->' id='ProductState_<!--@ProductState.Option.Value-->'<!--@If Defined(ProductState.Option.IsSelected)--> selected<!--@EndIf(ProductState.Option.IsSelected)--> >
                <!--@ProductState.Option.Name-->
                </option>
                <!--@ProductState.Option.IsSelected-->
                <!--@LoopEnd(ProductState.Options)-->
            </select>

This returns an null when saving the product in the following Base.Request:

Base.Request("ProductState")

But with a radio button list the Base.Request returns a value:

        <label class="sales-state" for="ProductState">

            <!--@LoopStart(ProductState.Options)-->

            <input class="for product-state" type="radio" name="ProductState" value="<!--@ProductState.Option.Value-->" id="ProductState_<!--@ProductState.Option.Value-->"<!--@If Defined(ProductState.Option.IsSelected)--> checked<!--@EndIf(ProductState.Option.IsSelected)-->/><label for="ProductState_<!--@ProductState.Option.Value-->"><!--@ProductState.Option.Name--></label><br />
            <!--@LoopEnd(ProductState.Options)-->

        </label>

Anyone got any ideas or input where i'm going wrong with the dropdownlist?


Replies

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply
This post has been marked as an answer

Your <select> element is missing a name attribute, and thus its value is never submitted. Try this:

<select name="ProductState">

Cheers,

Imar

Votes for this answer: 1
 
Hasan H. Samanci
Reply

Thanks a lot Imar.

That was the issue. 

 

You must be logged in to post in the forum