Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 275 Vote(s) - 3.49 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to add multiple dropdown form with submit button combine value and go to url

#1
I want the submit button to act on the combined values in the two didferent dropwdown menu's in the form.

For example... west and winter is a different URL then west and summer

I'm struggeling for days to make this work. I feel some how this must be possible. Please help!

This is the code I use. When I replace the value to a URL. The URL will be loaded on submit (go). I want the values of the first dropdown and second dropdown to be counted and the result should be a URL on submit. Finaly there should be 16 different URLs.

<!-- begin snippet: js hide: false -->

<!-- language: lang-js -->

$(document).ready(function () {
$(".go-btn").click(function () {
location = $("#selection option:selected").val();
});
});


<!-- language: lang-html -->

<div class="selCont">
<h2>pick an option</h2>

<select id="selection" name="selection">
<option value="1">West</option>
<option value="2">East</option>
<option value="3">North</option>
<option value="4">South</option>
</select>

<select id="selection" name="selection">
<option value="1">Winter</option>
<option value="2">Spring</option>
<option value="3">Summer</option>
<option value="4">Fall</option>

</select>
<button class="go-btn" type="submit">Go</button>
</div>

<!-- end snippet -->

Reply

#2
Try giving both selector elements a unique id. Here's a working snippet:


<!-- begin snippet: js hide: true -->

<!-- language: lang-js -->

(function () {

$(".go-btn").on(
'click',
function (e) {
// within this function you should figure out the url
// to redirect to, depending on the selected values
// the next line only shows the text of selected values
$('#selected').html([$('#select1 option:selected').text(),
$('#select2 option:selected').text()].join('/'));
});

}());

<!-- language: lang-html -->

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>

<div class="selCont">

<h2>pick an option</h2>

<select id="select1">
<option value="1" selected>West</option>
<option value="2">East</option>
<option value="3">North</option>
<option value="4">South</option>
</select>

<select id="select2">
<option value="1" selected>Winter</option>
<option value="2">Spring</option>
<option value="3">Summer</option>
<option value="4">Fall</option>
</select>

<button class="go-btn" type="submit">Go</button>

</div>
<div id="selected"></div>

<!-- end snippet -->

Reply

#3
Try this code:

jQuery( document ).ready(function( $ ) {
$( ".go-btn" ).click(function() {
// Grab text from select boxes
var firstSelection = $( "#selection1 option:selected" ).text();
var secondSelection = $( "#selection2 option:selected" ).text();

// Set URL, change as necessary
var url = "http://www.example.com/" + firstSelection + "/" + secondSelection;

// Redirect
window.location.href = url;
});
});

Also, change the IDs on your select boxes:

<select id="selection1">
<option value="1">Hands</option>
<option value="2">Feet</option>
<option value="3">Body</option>
</select>
<select id="selection2">
<option value="1">Acne</option>
<option value="2">Dry Skin</option>
<option value="3">Redness</option>
<option value="4">Sensitivity</option>
</select>

Thanks,



Andrew
Reply

#4
So what I need to do now is for example:
If a user selects:

I am: "Someone who works with my hands"
and I need: "UV Protection"

Once they click Go it will take them eg:

[To see links please register here]


or

If user clicks:
I am: "Someone who works with my feet"
and I need: "Acne"

Once they click Go it will take them eg:

[To see links please register here]



<!-- begin snippet: js hide: false -->

<!-- language: lang-js -->

jQuery( document ).ready(function( $ ) {
$( ".go-btn" ).click(function() {
// Grab text from select boxes
var firstSelection = $( "#selection1 option:selected" ).text();
var secondSelection = $( "#selection2 option:selected" ).text();

// Set URL, change as necessary
var url = "http://www.example.com/" + firstSelection + "/" + secondSelection;

// Redirect
window.location.href = url;
});
});

<!-- language: lang-html -->

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>

<div class="selCont">

<h2>Me Time</h2>

I Am:
<select id="select1">
<option value=" " selected="selected">- Select -</option>
<option value="1">Someone who works with my hands</option>
<option value="2">Someone who works wit my feet</option>
<option value="3">Someone who works with my body</option>
</select>

and I need:
<select id="select2">
<option value=" " selected="selected">- Select -</option>
<option value="1">UV Protection</option>
<option value="2">Acne</option>
<option value="3">Dry Skin</option>
<option value="4">Eczema</option>
<option value="5">Itchy Relief</option>
<option value="6">Redness</option>
<option value="7">Sensitive Skin</option>
</select>

<button class="go-btn" type="submit">Go</button>

</div>
<div id="selected"></div>


<!-- end snippet -->
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through