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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:38:21+00:00 2026-05-28T00:38:21+00:00

Consider this HTML: <form id=MyForm> <input name=Input1/> </form> To get the form, I would

  • 0

Consider this HTML:

<form id="MyForm">
    <input name="Input1"/>
</form>

To get the form, I would do this:

var form = document.getElementById("MyForm");

Now I know that to get Input1 from the form I can do this:

var input1 = form.Input1;

Can you give me the code for another way to access any form control from a form, by using the name attribute?

I would imagine that a possible answer could involve recursing through descendants of the form and checking for a control with the attribute named “name”, with the value “Input1”.

Please provide an answer that does not require additional libraries.

The following is not important

In case you’re wondering why I’m asking this: I’m using software called Script#, which compiles C# into JavaScript. The current version of Script# doesn’t support [form element].[name attribute value], so I’m looking for an alternative way to do this.

  • 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-28T00:38:22+00:00Added an answer on May 28, 2026 at 12:38 am

    An alternative you might be able to use is:

    document.getElementById("MyForm")["Input1"]
    

    Either that, or you need to assign an ID directly to the form element, and reference that. Otherwise, multiple forms may contain an element of the same name, and without including the form as part of the reference, you’d have an ambiguity.

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

Sidebar

Related Questions

Consider this HTML: <form id=MyForm> <input name=Input1/> </form> In Script# I do this: FormElement
Consider this HTML snippet: <input type='file' id='fileUpload' /> To get access to this control
Let's consider this simple code: <h:form id=myForm> <h:inputText id=myInput> <a4j:support event=onchange actionListener=#{myBean.doSomething}/> </h:inputText> </h:form>
Please consider the following HTML: <input type='text' id='name'/> <option id='option'> <select value='1'>hi</select> <select value='2'>bye</select>
Consider this page @ http://www.bloodbone.ws/screwed.html I need to be able to have the a.grow
This problem is only in IE. Consider the following HTML: <html> <body> <div style='position:absolute;left:1em;right:1em;top:1em;bottom:1em;overflow:auto;>
Consider this (snipped) example <!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd> <html xmlns=http://www.w3.org/1999/xhtml>>
Consider this code: <script type=text/javascript> if ('mySuperProperty' in window) { alert(window['mySuperProperty']); } var mySuperProperty
consider this html code <textarea> <object> <embed></embed> <div></div </object> </textarea> If i issue the
Consider this document fragment: <div id=test> <h1>An article about John</h1> <p>The frist paragraph is

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.