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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:02:04+00:00 2026-05-20T11:02:04+00:00

I want to enter different rooms with on button. How is this possible in

  • 0

I want to enter different rooms with on button. How is this possible in Javascript. For example, there are three rooms, “Kitchen, toilet and bedroom”. How can I use JS to enter any of these rooms depending on my choice. so if i enter “kitchen” in the input box its gonna take me to kitchen.php, if I enter toilet…the same button is going to take me to toilet.php etc.

This is the HTML input,

<form method="post">
<input style=""name="Text1" type="text"><br>
<input name="move" style="height: 23px" type="submit" value="Move">
</form>
  • 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-20T11:02:04+00:00Added an answer on May 20, 2026 at 11:02 am

    Just use a select field jsfiddle demo:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
    <html xmlns="http://www.w3.org/1999/xhtml"> 
    
    <head> 
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> 
    <title>Untitled 1</title> 
    <script type="text/javascript"> 
    function submitForm() {
        var myform = document.getElementById('myform');
        var mytext = document.getElementById('room');
        myroom = mytext.value.toLowerCase();
        if (myroom == 'kitchen') {
            myform.action = 'kitchen.php';
            myform.submit();
        } else if (myroom == 'toilet') {
            myform.action = 'toilet.php';
            myform.submit();
        } else if (myroom == 'bedroom') {
            myform.action = 'bedroom.php';
            myform.submit();
        } else return false;
    }
    
    window.onload = function(){
         document.getElementById('move').onclick = submitForm;
    }
    </script> 
    </head> 
    
    <body> 
    <form id="myform" name="myform" method="post"> 
        <input type="text" id="room" name="room" />
         <button id="move" name="move" style="height: 23px">Move</button> 
    </form> 
    </body> 
    </html> 
    

    On the php side create three files to test to see if this works, toilet.php, kitchen.php, and bedroom.php with the following code in all three files. make sure the file names are lower cased:

    <?php
    echo $_POST['room'];
    ?>
    

    Basically, based on the option that is selected, the JavaScript would change the form’s action url and submit. If none is selected it’ll return false and not submit. The submitForm function is attached to the move button with an onclick event.

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

Sidebar

Related Questions

In my application four TextArea is there and I want to enter only four
I want to allow user to enter only english alphabets and characters. How can
I want a functionality ,where user can enter some text in a textbox,and based
I want to build a site where the user can enter text and format
I want to give users a text area where they can enter text. Later
I want people to enter there first name then middle name then last name
I have a few different input textboxes which you can enter a command into,
I need this for a chat box. When the user press enter, I want
I want to enter floating point values to some of the record. So if
Scenario: I want to enter an address (Sweden, Stockholm) into an inputfield and get

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.