Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. Can I Link a checkbox to a TextBox?

Can I Link a checkbox to a TextBox?

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netquestionworkspace
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    woaksie
    wrote on last edited by
    #1

    First this is what I am trying to achieve: I want a single checkbox and a textbox. If the checkbox is checked (selected) I want the textbox to instantly become invisible or read-only. If the checkbox is un-checked I want the textbox to be visible and writable. The environment is ASP.NET mobile controls i.e. a browser on a mobile phone, PDA, etc. Ideally I don’t want to postback when the checkbox is selected. I assume I need a SelectionList to create a checkbox but where do I go from there? Thanks. John.

    P 1 Reply Last reply
    0
    • W woaksie

      First this is what I am trying to achieve: I want a single checkbox and a textbox. If the checkbox is checked (selected) I want the textbox to instantly become invisible or read-only. If the checkbox is un-checked I want the textbox to be visible and writable. The environment is ASP.NET mobile controls i.e. a browser on a mobile phone, PDA, etc. Ideally I don’t want to postback when the checkbox is selected. I assume I need a SelectionList to create a checkbox but where do I go from there? Thanks. John.

      P Offline
      P Offline
      Paul Watson
      wrote on last edited by
      #2

      Say you have this:

      <input type="checkbox" onclick="setTextBox(this);" />
      <input type="text" id="textboxTest" />

      then you would have this as a JS function:

      function setTextBox(checkboxTest)
      		{				
      			if (checkboxTest.checked)
      				document.getElementById("textboxTest").disabled = true;
      			else
      				document.getElementById("textboxTest").disabled = false;
      		}
      

      regards, Paul Watson Bluegrass South Africa Anna-Jayne Metcalfe wrote: "Cynicism has it's place in life - but it should be kept well away from your inner self." Crikey! ain't life grand?

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups