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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T21:56:33+00:00 2026-06-05T21:56:33+00:00

Hi I have several text input boxes, and i have a clear button, they

  • 0

Hi I have several text input boxes, and i have a clear button, they all share the same name and i wish to clear them all using one function, and this be done without ID’s as that takes up too much space
my code thus far looks like this:

var Id;
var Name;
function Check(id, name)    {
Id = document.getElementById(id);
Name = document.getElementById(name);
if (Id.value == id) {
    Name.checked = true;
    alert('correct');
    return;
} else  {
    Name.checked = false;
    alert('incorrect');
}
}
function ClearP()   {
document.getElementsByName("input").innerHTML = '';
}

my html looks like this

<div class="content">
                    <div class="main_story" style="margin-bottom:20px;">
                        <p class="sentence">the word to go here -></p>
                        <input id="here" name="input" class="sentence" type="text" size="7">
                        <p class="sentence">is here</p>
                        <button style="float:right" id="correct" onClick="Check('here', 'aShow');">Correct?</button>
                        <input style="float:right" name="aShow" id="aShow" type="checkbox" value="">
                    </div>
                    <div class="main_story" style="margin-bottom:20px;">
                        <p class="sentence">the word to go here -></p>
                        <input id="you" name="input" class="sentence" type="text" size="7">
                        <p class="sentence">is you</p>
                        <button style="float:right" id="correct" onClick="Check('you', 'bShow');">Correct?</button>
                        <input style="float:right" name="bShow" id="bShow" type="checkbox" value="">
                    </div>
                    <button onClick="ClearP();">Clear</button>
                </div>

all help is much appreciated 🙂 thank you 🙂

  • 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-06-05T21:56:35+00:00Added an answer on June 5, 2026 at 9:56 pm
    function ClearP(){
        var inputs = document.getElementsByTagName("input");
        for(var i=0;i<inputs.length;i++)
            inputs[i].value = '';
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have several INPUTs: <input type=text name=entry[1] value=aaa id=firstEntry /> <input type=text name=entry[2] value=bbb
I have several text box's where input is added. All these input are then
I have several paragraphs of text that are being stripped of all of their
I have one form with several text fields and one button. When i enter
I have a form with several text boxes on it. I only want to
I have several select boxes and textboxes with the same class and I have
Quick question about CI. I have a view with a form, several text input
I have several forms(user can add new form dynamically) in one page, they're all
I have a page with several Ajax.InPlaceEditor fields. Some are single line (text input
I have several areas where I use AJAX to submit text fields. var name

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.