Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9086119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T21:24:39+00:00 2026-06-16T21:24:39+00:00

When I create new product, I need to define it is local or not.

  • 0

When I create new product, I need to define it is local or not. Product model has IsLocal property in boolean type.

Here is view:

<form action="/Product/Create" method="post" id="Product_Form">
        <div>
            <label>Local</label>
            <input type="radio" name="IsLocal" id="IsLocal" value="yes" checked="checked" tabindex="10" />
        </div>

        <div>
            <label>Not local</label>
            <input type="radio" name="IsLocal" value="no" tabindex="11" />
        </div>

      <div id="yes">
          //some fields looks when product is local.
        </div>
        ...
        <input type="submit" value="Create" class="large" tabindex="17" />
 </form>

Firstly, Local radiobutton is checked. When I check Not local, some fields hide with this code.

<script>
      $("input:radio[name='IsLocal']").click(function () {
      $('#yes').hide();
      $('#' + $("input:radio[name='IsLocal']:checked").val()).show(); });
</script>

But, I should send values to controller with jquery function which i found.

jQuery.post('/Product/Create', {
                    Name: jQuery('#Name').val(),
                    IsLocal: jQuery('#IsLocal').val(),
                    ImagePath: jQuery('#ImagePath').val(),
                    CategoryId: jQuery('#CategoryId').val(),
                    Price: jQuery('#Price').val(),
                    ............................ 
                    formname: 'Product_Form',
                    formtype: 'ProductF'
}

Problem is that, IsLocal is always false. But, other field’s values goes to controller correctly. How should I do that, to send IsLocal value depending on its checking?
(Sorry for bad English)

Edit:

I changed <input> with @Html.RadioButtonFor() :

@Html.RadioButtonFor(model => model.IsLocal, true, new { id = "IsLocal_true", value = "yes", Checked = "checked" })

@Html.RadioButtonFor(model => model.IsLocal, false, new { id = "IsLocal_false", value = "no" })

IsLocal works, but now hiding of panel doesnt work.
Now, How must I change this script? To hide and show <div id="yes"> tag.

<script>
      $("input:radio[name='IsLocal']").click(function () {
      $('#yes').hide();
      $('#' + $("input:radio[name='IsLocal']:checked").val()).show(); });
</script>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T21:24:41+00:00Added an answer on June 16, 2026 at 9:24 pm

    Try this: jQuery(‘#IsLocal’).is(“:checked”)

    jQuery.post('/Product/Create', {
                        Name: jQuery('#Name').val(),
                        IsLocal: jQuery('#IsLocal').is(":checked"),
                        ImagePath: jQuery('#ImagePath').val(),
                        CategoryId: jQuery('#CategoryId').val(),
                        Price: jQuery('#Price').val(),
                        ............................ 
                        formname: 'Product_Form',
                        formtype: 'ProductF'
    }
    

    For Your Edit

    See demo here http://jsfiddle.net/43GsG/4/

    HTML:

    @Html.RadioButtonFor(model => model.IsLocal, true, new { name = "IsLocal", id = "IsLocal_true", value = "yes", Checked = "checked" })
    
    @Html.RadioButtonFor(model => model.IsLocal, false, new { name = "IsLocal", id = "IsLocal_false", value = "no" })
    

    JS:

    $("input[name=IsLocal]").click(function () {
        if($('#IsLocal_true').is(":checked")){
          $('#yes').show();
        }
        else {
          $('#yes').hide();
        }
      });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How to create new type in c#? For example byte has range 0 to
Planning to create a new website for our product using ASP.NET MVC 4. Site
I am new with MVC I am trying to create a small product form
I created a new product type and everything works except the indexing of the
In mvc3 application when I create new product, I want to add it's create
I am trying to create a view with multiple product listing in it. An
When new product is created in Magento, then how exactly that get saved in
I create new desktop with CreateDesktop and want to get it's DC & RC.
I create new blank solution. Add exist web site. Structure: Solution E:...\projectname Folders: bin
Code to create new form instance of a closed form using form name I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.