html onClick condition Link - html

SO basically im trying to create a button on a html webpage that uses or checks the values from two drop down lists and relative to that it will link to the appropriate page.
But the IF statements dont seem to work...
i tried using regular href Links but this didnt end well, such as When to use onclick in HTML?
here is my code:
<select name="Module">
<option value="Module 10">Module 10</option>
<option value="Module 11">Module 11</option>
<option value="Module 20">Module 20</option>
<option value="Module 60">Module 60</option>
<option value="Module 70">Module 70</option>
<option value="Module 85">Module 85</option>
</select>
<select name="Sector">
<option value="Sector1">Sector1</option>
<option value="Sector2">Sector2</option>
<option value="Sector3">Sector3</option>
<option value="Sector4">Sector4</option>
</select>
<FORM>
<INPUT type="button" value="OK"
onClick="if (( Module=='Module 10') && (Sector=='Sector1)) {location.href='M10_S1.html'}">
</FORM>

This should be what you want:
<form>
<select name="Module">
<option value="1">Module 1</option>
<option value="2">Module 2</option>
<option value="3">Module 3</option>
<option value="4">Module 4</option>
<option value="5">Module 5</option>
<option value="6">Module 6</option>
</select>
<select name="Sector">
<option value="1">Sector1</option>
<option value="2">Sector2</option>
<option value="3">Sector3</option>
<option value="4">Sector4</option>
</select>
<input type="button" value="Confirm" onClick="location.href='./M' + Module.value + '_S' + Sector.value + '.htm'">
</form>
The file names will be formatted as "M#_S#.htm"

Related

How to require a selection in my select element on my signup form [duplicate]

This question already has answers here:
How do I make a field required in HTML?
(16 answers)
Closed 2 months ago.
<label for="select-choice">Birthday:</label>
<select name="select-choice" id="select-choice">
<option value="0" selected disabled>Month</option>
<option value="january">Jan</option>
<option value="february">Feb</option>
<option value="march">Mar</option>
<select name="birthday-day" id="day">
<option value="0" selected disabled>Day</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<select name="birthday-year" id="year">
<option value="0" selected disabled>Year</option>
<option value="2015">2015</option>
<option value="2014">2014</option>
<option value="2013">2013</option>
<option value="2012">2012</option>
<option value="2011">2011</option>
The Sign Up or Register page is okay but I could not validate the birthday, When I try filling it on a browser I expect it to demand or require birthday option, every other input option was demanding or requiring me to input an information but if I purposely did not fill the birthday and hit the submit button it will go through just like that, please how do I validate the birthday using HTML?
You just need to add "required" to each of your selects and then just add an empty value instead of a "0" value. When you press a button, it will detect it has no value and will automatically make the select required.
<form>
<label for="select-choice">Birthday:</label>
<select name="select-choice" id="select-choice" required>
<option value="">Month</option>
<option value="january">Jan</option>
<option value="february">Feb</option>
<option value="march">Mar</option>
</select>
<select name="birthday-day" required>
<option value="">Day</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
<select name="birthday-year" id="year" required>
<option value="">Year</option>
<option value="2015">2015</option>
<option value="2014">2014</option>
<option value="2013">2013</option>
<option value="2012">2012</option>
<option value="2011">2011</option>
</select>
<button>submit</button>
</form>

How select POST values from different select options?

For example, I have 3 different select options:
<select name="FirstOption">
<option value="1">First</option>
<option value="2">Second</option>
<option value="3">Third</option>
</select>
<select name="SecondOption">
<option value="1">First</option>
<option value="2">Second</option>
<option value="3">Third</option>
</select>
<select name="ThirdOption">
<option value="1">First</option>
<option value="2">Second</option>
<option value="3">Third</option>
</select>
So, when I click a button, I want to get all the values of all 3 select options and insert the values into the database.
Right now, I'm using this button with a href tag but looks like it's very wrong:
Reserve
What's the best way to do this?
Wrap the selects inside a form and put a submit button.
Add your ID as hidden fields.
Your HTML code should now be something like this :
<form method="post" action="../reservation-confirmation">
<select name="FirstOption">
<option value="1">First</option>
<option value="2">Second</option>
<option value="3">Third</option>
</select>
<select name="SecondOption">
<option value="1">First</option>
<option value="2">Second</option>
<option value="3">Third</option>
</select>
<select name="ThirdOption">
<option value="1">First</option>
<option value="2">Second</option>
<option value="3">Third</option>
</select>
<input type="hidden" value="" name="tour_id" >
<button type="submit" name="submit'> Submit </button>
</form>
On the server-side, process the responses by targeting
if(isset($_POST['submit']))
$FirstOption$=$_POST['FirstOption']
$SecondOption$=$_POST['SecondOption']
$ThirdOption$=$_POST['ThirdOption']
... //Add them into your database.
Remember to use prepared statements.

Dropdown default selected value not working with angular js

I have the following select list:
<select ng-change="LoadCarType()" ng-model="rowsPerPage">
<option selected="selected">5</option>
<option>10</option>
<option>50</option>
<option>100</option>
</select>
In this case defult selection is not working.If I inspect the element I find the following output:
<select ng-change="LoadCarType()" ng-model="rowsPerPage" class="ng-pristine ng-valid ng-empty ng-touched">
<option value="? undefined:undefined ?"></option>
<option selected="selected" value="5">5</option>
<option value="10">10</option>
<option value="50">50</option>
<option value="100">100</option>
</select>
If I remove the part:
ng-change="LoadCarType()" ng-model="rowsPerPage"
then everything is ok.

Select Menu - Select Property - HTML

Is There a way To set selected="selected" to selected="notselected" Or something like that. i tried selected="false" but it did not doing anything
Thank You For all your answers
You can do it easily with little bit jquery. Please have a look the demo jsfiddle
Demo
Markup:
<select multiple="multiple" name="remaintextarea" id="studentremain" size="10">
<option value="one">One</option>
<option value="two">Two</option>
<option value="three">Three</option>
</select>
<button type='button' id='selectall'>Select All</button>
<button type='button' id='deselectall'>De-Select All</button>
JS:
$('#selectall').click(function() {
$('#studentremain > option').attr("selected", "selected");
});
$('#deselectall').click(function() {
$('#studentremain > option').removeAttr("selected");
});
Just don't specify selected for the options you don't want selected:
<select>
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="vw">VW</option>
<option value="audi" selected>Audi</option>
</select>
This may help
<select>
<option disabled selected> -- select an option -- </option>
<option>Option 1</option>
<option>Option 2</option>
<option>Option 3</option>
</select>
You use selected property in html then it will select the one you added selected on just like this
<option value="bike" selected></option>

How to link page like href="#page_3" in select option in intel xdk?

<select id="byplanname" name="byplanname" style="display:none;">
<option value="Select Plan Name" multiple="multiple">Select Plan Name</option>
<option value="815" href="#page_3">815</option>
<option value="816">816</option>
<option value="816">817</option>
<option value="818">818</option>
<option value="820">820</option>
<option value="821">821</option>
<option value="822">822</option>
<option value="823">823</option>
<option value="904">904</option>
</select>
The href="#page_3" is not working ,Please tell me proper linking in intel xdk..thanx
Try something like this:
<select id="byplanname" name="byplanname" onchange="location = this.options[this.selectedIndex].value;">
<option value="google.com">815</option>
<option value="google.com">816</option>
<option value="google.com">817</option>
<option value="google.com">818</option>
<option value="google.com">820</option>
<option value="google.com">821</option>
<option value="google.com">822</option>
<option value="google.com">823</option>
<option value="google.com">904</option>
</select>
For using #page_3 you will have to put in your URL before that so it would be website.com/#page3 in the value field
JSFiddle:
http://jsfiddle.net/fqB3Z/