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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:18:30+00:00 2026-05-28T05:18:30+00:00

I have a code javascript: <form onsubmit=return false; action=> <input type=radio name=type id=type0 value=0

  • 0

I have a code javascript:

<form onsubmit="return false;" action="">
<input type="radio" name="type" id="type0" value="0" onclick="toggleSet(this)" checked />type 0
<input type="radio" name="type" id="type1" value="1" onclick="toggleSet(this)" />Type 1
</form>
<script>
function toggleSet() {
    for(var i=0; i<document.form.type.length; i++) {
        if(document.form.type[i].checked) {
            var type = document.form.type[i].value;
        }
    }
    alert(type);
}
</script>

ouput error: document.form is undefined, how to fix it ?

  • 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-28T05:18:31+00:00Added an answer on May 28, 2026 at 5:18 am

    The form property of document does not exist. You’re probably confused with the document.forms HTML collection:

    document.forms[0];              //First <form> element
    document.forms['name_of_form']; //Points to <form name="name_of_form">
    

    Fixed code:

    function toggleSet() {
        var form = document.forms[0];
        var type; //Declare variable here, to prevent a ReferenceError at the end
        for(var i=0; i<form.type.length; i++) {
            if(form.type[i].checked) {
                type = form.type[i].value;
                break; // After finding an occurrence, break the loop:
                       // You expect only one value
            }
        }
        alert(type);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a code javascript of a action form: <form name=myform onsubmit=return OnSubmitForm(); method=post>
Hello i have this form filling javascript: function onLine(code,nn) { document.writeform.bericht.value+=code; document.writeform.bericht.focus(); document.writeform.nickname.value+=nn; write1();
I have JavaScript code which copies the value of input file and paste it
Javascript I have code that will hide various sections in a MS CRM form
lets'say i have a form, with like this : <form name=frmMail method=POST action=save.do dojoType=dijit.form.Form
i have problem in javascript email validation, I wrote code something like, //emp.php <form
I have this code <html> <head> <script type=text/javascript src=my-search.js></script> </head> <body onLoad=my_Init();> <div> <form
I have javascript code embedded inside a html template file. When I load this
As you may know, when we have this code in Javascript : function getName()
i have this javascript code to which i want to add the jquery fade-in

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.