Open url based of input - html

I would like to make some field (For example using Form and Select tags)
<form method="GET" action="baseURL">
<select name="agent_id" required>
<option value="1">Agent Homer</option>
<option value="2">Agent Lenny</option>
<option value="3">Agent Carl</option>
</select>
<input type="submit" value="Submit">
</form>
and I would like after clicking on "Submit" to open url in browser which would be made from baseURL and selected option.
The only problem is that I cannot use javascript. (Let's say that I only can do this in pure HTML)
Is there even a way to do this?

While, perhaps, not in the specific format you want the URL to be in (it will be baseURL?agent_id=1), the code you already have will do that.
If you want the URL to be in a different format (such as baseURL/1) then you'll need to involve a programming language (HTML is not a programming language).
You can use any server-side language you like. Specify the URL to a server side program in the action attribute, construct the URL you want, then redirect to it.
You could also use client-side JS, but you've rejected that.

Related

why assign a name/id to a <select> in a drop down list

I'm looking at some code my teacher wrote, here is the code snippet for an HTML drop down list:
<form name="year" id="year">
<select name="year" id="year"> <!--What is the purpose of naming select?-->
<option>Freshman</option>
<option>Sophomore</option>
<option>Junior</option>
<option>Senior</option>
<option>Grad Student</option>
</select>
</form>
What is the purpose of naming the select statement? What could this be used for later in the code?
Thank you
The most basic explanation: name attribute is used when submitting the form and retrieving on the server-side. The id attribute is used for JavaScript functions, such as a change event.

Activate a textbox if I select a particular option in drop down box in html without using java

I have to make a webpage in HTML, and strictly not use Java .
Do You wish to enter Scientific Name:<select name="snc">
<option value="n" selected>No</option>
<option value="y">Yes</option>
</select>
Scientific Name: <input type="text" name="sn"><br>
All solutions i found for this had java used.
Is it possible for me to make the "Scientific Name" Box come only if the option is "Yes"
Remember java in any form is not allowed.
If possible, please tell me how.
It is not possible to make a input tag change it's visibility without some script function.
It is possible to validate your input via your server side scripts.
If you need more information, please ask.

Is it necessary to have Submit button for each <form>?

If I'm using a dropdown using <select> is it ok. I'm asking in terms of Web Accessibility, Web Standards.
<form action="#" class="country-selection">
<select>
<option title="images/india.jpg">India</option>
<option title="images/india.jpg">USA</option>
</select>
</form>
Yes, because the page should work without client-side scripting too. The proper way is to include a real action attribute value, referring to a server-side script, and include a submit button, because that is the only way to ensure submittability when scripting is off. You can wrap it inside a noscript element so that it does not appear when it is not needed, i.e. when client-side scripting is enabled:
<noscript><input type=button value=Change></noscript>
The title attribute values may be displayed or otherwise presented to the user, so they should either contain something sensible (not URLs) or be absent. If you need to include some data for client-side processing, use data- attributes.
No, that is specifically called out as a failure in WCAG 2.0: F37: Failure of Success Criterion 3.2.2 due to launching a new window without prior warning when the status of a radio button, check box or select list is changed.
If you don't have any submit button it is acceptable after all it is an element of form tag and if it is not required you may not add it with in form. This will not broke any web standard.
Sure it's ok, noone is forcing a submit button on you, but you probably won't need an action on the form either.
If you want to submit the form when the user makes a selection, try this
<form action="#" class="country-selection">
<select onChange="javascript:submit()">
<option title="images/india.jpg">India</option>
<option title="images/india.jpg">USA</option>
</select>
</form>

Submit form when selected value of select element is changed without javascript

Hi the question is pretty simple.
<select name="justanumber">
<option value="1" selected="selected">1</option>
<option value="2"></option>
</select>
when selected value is changed i have to do a form post.
But the problem is to do this WITHOUT javascript.
I'm not sure is it possible to do that, the best result i have archived is submit form using label for.
No, that is not possible without using client script.
I suggest that you use script for how you want it to work normally, and supply a submit button as a backup for those who can't use script.
No, there is no auto-submit attribute for such things -- however, there is a way around it:
CSS:
#jsOn .Submit {
display: none;
}
HTML:
<form id="my_form" action="">
<select id="justanumber" name="justanumber">
<option value="1" selected="selected">1</option>
<option value="2"></option>
</select>
<input type="submit" value="Go!" class="Submit" />
</form>
JavaScript:
var visible_root = document.getElementsByTagName("body");
while (visible_root.length < 1) {
continue;
}
visible_root = visible_root[0];
visible_root.id = "jsOn";
document.getElementById("justanumber").onchange = function() {
document.getElementById("my_form").submit();
};
When people without JavaScript arrive at your site they will see a submit button. When people with JavaScript turned on arrive at your site the submit button will be hidden and an onchange event will be added to the select element. (Alternately you could add an event listener, if you have a JavaScript library that normalizes all of the events for you.)
I don't believe this is possible without js. An obvious approach would be to set a submit button as the option's value (eg, <option><input type="submit"></option>). Unfortunately browsers will bark and moan, appending the input element after the select element. If the select determines the app flow, consider using another another UI element (eg, buttons, links, etc.).
Here is the answer.
Unfortunately, It's not possible.
<form action="aaa.php" method="post" name="autosubmit_select">
<select name="justanumber" onChange="document.autosubmit_select.submit();">
<option value="1" selected="selected">1</option>
<option value="2"></option>
</select>
</form>
agreed you must use javascript for this
please see this post How to submit form on change of dropdown list?
if your worried about users not having javascript enabled then i would suggest along with the given example in the post in the link you do this
<noscript>This form requires that you have javascript enabled to work properly please enable javascript in your browser.</noscript>
or something along those lines
other than that it is not possible to do this (currently) without the use of javascript
use a submit_button to submit while JS not enabled.
If JS enabled hide the button using JavaScript. Amazon did so.!
http://www.amazon.in/s/ref=nb_sb_ss_i_1_5?url=search-alias%3Delectronics&field-keywords=sd+card&sprefix=sd+ca%2Celectronics%2C401&crid=1M4KMJEGDLTEL
disable JS and see the sortby section top right corner.

Auto-append items from a select list

I have a list of different items within a select multiple list and I want to auto-append to a form that a user submits.
HTML of category multiple select list:
<select name="category[]" size="4" multiple="multiple" id="group">
<option value='7'>Faculty</option>
<option value='8'>Staff</option>
<option value='6'>Students</option>
</select>
I want to do something like:
<input type="hidden" name="category[7,8]" />
This will automatically assign the submission to the appropriate selected list items from within category[], without them ever seeing it.
This is stored within a database, so I need to accomplish it this way.
I know this does not work, but this should give you an idea of what I am trying to do.
A successful multiple-select control just gets submitted as having multiple values. E.g., if you selected "Faculty" and "Staff" in your list, what gets submitted is something like:
category[]=7&category[]=8
You can replicate this (at least in Firefox, haven't tested elsewhere) with two hidden inputs:
<input name="category[]" value="7" type="hidden"/>
<input name="category[]" value="8" type="hidden"/>
I believe this could be accomplished using a Javascript library (such as jQuery) to handle the change on the Selections and append/update the items in your hidden field. You could then also use Ajax to update your database with the selection when necessary.
Your specific requirements might not allow for the above though. Some additional information would be helpful for those viewing such as what backend you're using (php, asp.net, or if it is just static html) and if you are currently using javascript (or a library) to assist you in any other tasks.
I'll try to check back on updates to see if I can be of more specific help. (Note: I think I'm too low of reputation to be able to post this as a comment at the moment so had to do an answer instead.)