0

Could someone explain how I can capture data from two dropdown fields and when the submit button is pressed join these two selection values together to create a URL which is then called.

eg.

DropDown 1: Apple DropDown 2: Orange

When you click submit button it creates a url and loads:

http://www.fruittopick.com/apple-orange.html <-- it concats "apple" & "-" & "orange" & ".html" and then loads that page.

2 Answers 2

2

you can create one javascript function that is to be called when form is submitted, for example see below

function genURL()
{
var orange= document.getElementById('orangeCombo');
var apple= document.getElementById('appleCombo');
var finalURL="www.test.com"; // you can configure as per your need
finalURL= finalURL+orange+apple; // you can configure as per your need
window.location.href=finalURL; // to load generated URL
}

hope it help

Sign up to request clarification or add additional context in comments.

1 Comment

hey accept any answer, or comment if you still have any issues, if not any issue now then vote the answer by accepting the answer
1

if you don't mind a little php:

<?php
$orange = $_POST['orange']; //replace orange with the name of dropdown 1.
$apple = $_POST['apple']; //replace apple with the name of dropdown 2.
$location = "www.example.com/".$orange."-".$apple.".html";
header('Location: '$location);
?>

Set the form's action to a page that contains nothing but the code above. IIRC, it would even pass off any form information.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.