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

  • Home
  • SEARCH
  • 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 226303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:29:54+00:00 2026-05-11T19:29:54+00:00

I have a field in my model – call it ‘distance’ – and I

  • 0

I have a field in my model – call it ‘distance’ – and I want to write a view that contains both a checkbox and a textbox.

If the checkbox is checked, the textbox becomes disabled and ‘distance’ gets the value 0 when the form is submitted.

If the checkbox is not checked, ‘distance’ gets whatever value is in the textbox when the form is submitted.

Anybody have any guidance how to do this? It’s the logic of assigning a model value based on the state of both the controls that confusing me…

  • 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-05-11T19:29:54+00:00Added an answer on May 11, 2026 at 7:29 pm

    The UI behaviour can be accomplished with Javascript via an onclick event handler on the checkbox. The only value you need to submit is the input field whose value will be set to 0 or whatever is set manually.

    With jQuery you would have:

    $('#checkbox_id').click(function() { $('inputfield_id').val('0');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a field in a model that I want users to feel like
I have a text field in my model that contains markdown text. I need
I have a field on my User model that is protected because it determines
I have a M2M field in my django model project. In my view I
I want a Django model to have a date field in which the year,
Let's say I have User model and Post model. Post model contains field user_id
I have a field in my Rails model that has max length 255. I'm
I have some fields in a model that are ManyToMany, I want the ManyToMany
I have a field in my model that's of type DecimalField . Even though
I have a model that needs to have a field named complex and another

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.