in Education by (1.8m points)
newbie here, so thanks in advance for help! I have a Wordpress site with multiple taxonomies. I'd like to create a very simple form with two select boxes, one for each taxonomy. Then I'd like to use an HTML form with the get method to display posts matching the criteria they requested from the select boxes.

I'm able to do this easy enough if each of the two select boxes are filled out, I get a permalink something like:

testsite.com/?tax1=value1&tax2=value2

(ugly, I know, but it works).

What I can't figure out is what to do if they don't fill out both select boxes. Ideally it would only give the permalink for the one they fill in, so either:

testsite.com/?tax1=value1 or testsite.com/?tax2=value2

But instead I'm getting

testsite.com/?tax1=value1&tax2=Select+tax

here is my HTML

<form action="http://www.testsite.com/" method="get">

Season: <select name="season">

<option>Select season</option>

<option value="">Select season</option>

<option value="spring">Spring</option>

<option value="summer">Summer</option>

<option value="fall">Fall</option>

</select><br/>

Vacation type: <select name="vacations">

<option value="">Select vacation type</option>

<option value="beach">Beach</option>

<option value="ski">Ski</option>

</select><br/>

<input type="submit" />

</form>

I realize the answer is probably simple but I'm banging my head against a wall so any help is very very much appreciated. Thank you!

JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by (1.8m points)
You can still pass an empty parameter like

testsite.com/?tax1=&tax2=whatever_was_selected

or

testsite.com/?tax1=whatever_was_selected&tax2=

but, you would have to preselect one of the options for them like

<option selected="selected" value="">Select vacation type</option>

This way if the form is submitted and the user didn't change their selection it should still pass the parameter of but without a value.

Related questions

0 votes
asked Apr 6 in Education by JackTerrance (1.8m points)
...