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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:23:20+00:00 2026-06-18T02:23:20+00:00

I have a form with two integer-only text boxes, one group of radio buttons,

  • 0

I have a form with two integer-only text boxes, one group of radio buttons, and a submit button. I would like it to take the values of these three inputs, and use them to generate a URL with three variables, like so:

http://domain.com/file.php?var1=&var2=&var3=

EDIT: To clarify, the output is on the page, not in the URL. I have created a php image that displays different things, based on the URL variables, and this image should be able to be used on other sites as the user sees fit.

EDIT2: My basic HTML:

<form>
<input type="text" id="var1" />
<br />
<input type="text" id="var2" />
<br />
<br />
<input type="radio" name="var3" value="1" />
<br />
<input type="radio" name="var3" value="2" />
<br />
<br />
<input type="button" id="URLGenerate" value="Generate" />
</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-06-18T02:23:21+00:00Added an answer on June 18, 2026 at 2:23 am

    Well, here is how you can solve this problem:

    1. Create the HTML

    You need to assign a id to every text box (text boxes are defined as <input type="text"/> in html. Then you need the radio buttons which are defined as <input type="radio"/>. Make sure that all radio buttons have the same name attribute. Here is a short intro.

    2. Get the values with Javascript

    You can access every element by its id.

    3. Change the current URL

    After making the URL, you can change it by assigning to window.location in Javascript.

    I guess if someone wants to make it simpler, they have to type the code for you! 😉

    Update

    Using the code that you added to the question, I created a javascript program that solves the problem:

    //assign the button event handler
    document.getElementById( 'URLGenerate' ).addEventListener( 'click', onGenerate );
    
    //given the name of a radio button group, it returns the value of the selected radio button or null if none of them are selected
    function getRadioButtonValue ( name ) {
      var allRadios = document.getElementsByName( name );
      for ( var i = 0; i < allRadios.length; i++ ) {
        if ( allRadios[i].checked ) {
          return allRadios[ i ].value;
        }
      }
      return null;//or any other value when nothing is selected
    }
    
    function onGenerate() {
      //the base url
      var url = 'http://domain.com/file.php';
      //an array of all the parameters
      var params = [];
      //get the value from the edit box with id=var1
      params.push( 'var1=' + document.getElementById( 'var1' ).value );
      //get the value from the edit box with id=var2
      params.push( 'var2=' + document.getElementById( 'var2' ).value );
    
      //get the value of the radio box
      params.push( 'var3=' + getRadioButtonValue( 'var3' ) );
    
      //join all the parameters together and add to the url
      url += '?' + params.join( '&' );
      alert( url );
    }
    

    Here is a JSBin to try it live and you can see the HTML/JS here: http://jsbin.com/itovat/3/edit

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

Sidebar

Related Questions

I have a form with two combo boxes and couple of buttons. One of
I have a form with two text boxes, one select drop down and one
I have a form with two selectfields. I would like that when something is
I have a form that has two buttons on it, one yes, one no,
I have a form with two input text fields: <input id=ModelName_test_0 name=ModelName[test][0] type=text> <input
I have a form with two text_fields: <input type=text id=post_name name=post[name] /> <input type=text
I have a login form for my website. This login form have two text
I have a negative integer (4 bytes) of which I would like to have
I have two form fields on my view page, a date input (with a
I am using MVC3, EF Model first. I have a form with two DropDownList

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.