return product id using javascript

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
12 years ago
hi

I have three column in my page

1. Plan id (radio button)
2. duration
3. price

bind successfully with data from db,

1.     i have a button called submit.i want to validate, when i clicked on submit button, user has to select atleast one plan. i wanted to validate this part


2.  if user have selected plan.. i want to return plan id to method "AddToCartProduct"


I have herewith paste my code, It's very urgent.. Please help me

using (Html.BeginRouteForm("ShoppingCart", FormMethod.Post))
        {
        <table class="cart">
           @* <col  width="1"/>*@
            <col width="1" />
            <col width="1" />
            <col width="1" />
            <thead>
                <tr class="cart-header-row">
                    <th>
                        @T("PublisherSubscriptionSettings.ChoosePlan")
                    </th>
                 <th>
                        @T("PublisherSubscriptionSettings.Plan")
                    </th>
                    <th>
                        @T("PublisherSubscriptionSettings.Price")
                    </th>
                
                   @* <th class="end">
                        @T("ShoppingCart.ItemTotal")
                    </th>*@
                </tr>
            </thead>
            <tbody>
            <script language="javascript" type="text/javascript">
                function validate(id)
                {
                 var checked = false;
                  
                    if (id != 0)
                    {
                    var checked = true;
                    alert(id);
                    }

                }
                                         </script>
                @foreach (var item in Model.PublisherSubscriptionSettingsItem)
                {
                    <tr class="cart-item-row">
                    
                    <td>
                      <script language="javascript" type="text/javascript">
                          function validateRadioButtonList() {

                              var listItemArray = document.getElementsByName("removefromcart");
                              var isItemChecked = false;

                              for (var i = 0; i < listItemArray.length; i++) {
                                  var listItem = listItemArray[i];

                                  if (listItem.checked) {
                                      //alert(listItem.value);
                                      isItemChecked = true;
                                  }
                              }

                              if (isItemChecked == false) {
                                  alert('Please select a project!');

                                  return false;
                              }

                              return true;
                          }
                  </script>

                        <input id="removefromcart" type="radio" name="removefromcart" value="@(item.Id)" />
                    </td>                          
                  
                      
                            <td style="white-space: nowrap;">
                            <span class="productPrice">@item.SubscriptionPlan</span>
                            </td>

                             <td style="white-space: nowrap;" class="end">
                            <span class="productPrice">@item.Price</span>
                            </td>
                    
                     </tr>
                }
            </tbody>
        </table>
          <div class="clear">
        </div>
        
        <div class="checkout-buttons">
        <input type="button" value="@T("ShoppingCart.AddToCart")" class="productlistaddtocartbutton"  onclick="setLocation('@(@Url.RouteUrl("AddProductToCart", new { productId = Model.Id }))')"/>
        </div>
        }
12 years ago
Please tell.. how to get selected plan id

its urgent work. Please help me
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.