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

The Archive Base Latest Questions

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

After my test, The first way to write <form name=form > <input type=text id=tx1

  • 0

After my test,

The first way to write

<form name="form" >   
        <input type="text" id="tx1" value="123"><br>
    </form>
<script>
    alert(form.tx1.value);   

</script>

The second way to write

<form id="form" >   
        <input type="text" id="tx1" value="123"><br>
    </form>
<script>
    alert(form.tx1.value);   

</script>

The third way to write

<form id="form" >  
        <input type="text" id="tx1" value="123"><br>
    </form>
<script>
    alert(form.elements['tx1'].value);     

</script>

The forth way to write

<form id="form" >  
        <input type="text" name="tx1" value="123"><br>
    </form>
<script>
    alert(form.elements['tx1'].value);     

</script>

……..
Permutations and combinations are many, pay attention to the form’s id, name and input the id, the name, combined with the wording of the js, no matter how you write, are no problem. .
There is no standard at all. . . .

  • 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-29T10:58:12+00:00Added an answer on May 29, 2026 at 10:58 am

    Actually, there is a standard: http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109/html.html#ID-40002357

    On top of the standard, most browsers implement additional features.

    The safest way to refer to form elements through a named collection is:

    <form name="formname">
        <input type="text" name="tx1" value="123">
    </form>
    <script>
    alert(document.forms['formname'].elements['tx1'].value);     
    </script>
    

    document.forms is a HTMLCollection of <form> elements. In each of these form, the elements property is a collection of all form input elements. All elements have to be referred by name.

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

Sidebar

Related Questions

Is there a way to make running junit test to stop after a test
I've trying to get some vertical text on a little test webpage after reading
After test driving Google Chrome for 30 minutes or so, I like it, even
How can I run a certain cleanup task after my Test target runs, regardless
After reading the Test-and-Set Wikipedia entry , I am still left with the question
I have (after quite a bit of work) a web test that will upload
Im trying to test my successfully creates a new user after login (using authlogic).
I don't know if I should test my @Entity-annotated Pojos. After all, there are
After reading the Head First Design Patterns book and using a number of other
I wrote a simple script to solve a logic puzzle, the type of puzzle

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.