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

  • Home
  • SEARCH
  • 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 662933
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:26:01+00:00 2026-05-13T23:26:01+00:00

I have a form with 2 text inputs and 2 radio buttons, as below:

  • 0

I have a form with 2 text inputs and 2 radio buttons, as below:

<form id="form1" method="get" onSubmit="exec()" action="default.html">
   <label>First input<label>
   <input type="text" id="input1"/><br />
   <label>Second input</label>
   <input type="text" id="input2"/><br />
   <label>Radio button 1</label>
   <input type="radio" id="radio1"/>
   <label>Radio Button 2</label>
   <input type="radio" id="radio2"/><br />
   <input type="submit" value="Search">
</form>

Once the user hits the Search button the exec() method will be invoked, and this is what I am looking for help with. As you can see from the code above the default action is pointing to a page called default.html, but this could change depending on the input box the user entered text into and the radio button selected. So I think my exec() method should look something like this:

function exec()
{
    if(document.getElementById("radio1").checked) && 
    if(document.getElementById("input1").**has text entered by user**
    {
        document.getElementById("form1").setAttribute("action", "AnotherPage.html")
    }
}

I think the code I have there should work, that is if I knew what the syntax should be where I have entered “has text entered by user”. Can anyone tell me what that syntax should be? Am I going the right way about doing this or is there a better way?

Thanks in advance.

  • 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-13T23:26:01+00:00Added an answer on May 13, 2026 at 11:26 pm

    document.getElementById(“input1”).has text entered by user

    should be

     document.getElementById("input1").value.length > 0
    

    I would strongly recommend spending 10 minutes looking a jQuery. Just reference the jquery.js in your page and you’ll eliminate your next headache which is cross browser incompatibility.

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

Sidebar

Related Questions

Please see the form HTML code below <form method=post action=register> <div class=email> Email <input
I have a an HTML form which contains the YAHOO rich text editor on
I have a few text boxes and buttons on my form. Lets say txtBox1
I have below code in html <div id=divTest> Hello <input type=text id=txtID/> <input type=text
I have a form which contains a 'gender' label and two radio buttons'male' and
I have this input in a form: <input type=text value=<script src='/js/script.js' type='text/javascript'></script> name=embed/> The
I have an asp.net text form that contains numerous decimal fields that are optional.
I have a form with checkboxes and then text to the right of the
I have several strings in the rough form: [some text] [some number] [some more
I have a form with a textarea. Users enter a block of text which

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.