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 6116667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:13:57+00:00 2026-05-23T15:13:57+00:00

Cannot get this to work. First time using variables passed into functions. Unchecking radio

  • 0

Cannot get this to work. First time using variables passed into functions. Unchecking radio button should disable form field and vice versa. lineid variable distinguishes this radio/text input pair from 10 others.

My code:

<script type="text/javascript">
function disablefield(lineid){ 
if (document.getElementById(lineid).checked == true){ 
document.dupedit.lineid.disabled = false;
} else { 
document.dupedit.lineid.disabled = true;
} 
}
</script>

Subset of my HTML.

  • 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-23T15:13:58+00:00Added an answer on May 23, 2026 at 3:13 pm

    You need to pass a string into your disablefield function, so put the value in quotes when you pass it in. Something like:

    <input onclick="disablefield('2671997')" />

    This is because document.getElementById expects a string, not an integer.

    Secondly, to enable/disable the field, you need to use disabled = true; rather than = 'disabled'.

    document.dupedit.lineid is looking a for a field with name “lineid”, which doesn’t exist in your form. I would suggest giving the field an id and using document.getElementById again instead.

    If you want to continue using the name attribute, you will have to use document.getElementsByName instead. This returns an array of matching elements (since multiple elements can share the same name), but if in your code you know that the element in question is the only one with that name, you can do this:

    document.getElementsByName(lineid)[0].disabled = true;
    

    You can see a working version (I think this is how you wanted it anyway) here. And here is a version using getElementsByName.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have searched and searched but as yet still cannot figure this ole problem
SOLVED so i forgot to sudo apt-get php5-sqlite also. downvoters gonna downvote :D (fyi,
i'm writing an Android app and i've run into a bit of a roadblock
While it seems that this has been asked many times before, but there's a
This is probably the dumbest question ever here on stack Overflow. But I am
I'd like to validate the workflow within the design surface (in this case, Visual
I have an Amazon S3 account and have downloaded the AWSiOSSDK framework/SDK pack. The
I can find plenty of examples that show how to configure a URL to
Update Ignore the following. It turned out to be a bug restricted to Macruby
As a PHP programmer new to Perl working through 'Programming Perl', I have come

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.