Kompx.com or Compmiscellanea.com

JavaScript form submit

Windows : Internet Explorer 4.01+, Firefox 1.0+, Google Chrome, Opera 3.0+, Safari 3.1+, SeaMonkey 1.0+ [ 1 ].

Linux : Firefox 1.0+, Google Chrome / Chromium, Opera 5.0+, SeaMonkey 1.0+ [ 2 ].

Submitting a form using JavaScript. A dropdown list (form + select + multiple options) is processed without any submit button. Example:

HTML / XHTML. Code:

<form action="action.php" method="post">

<select name="page" required="required" onchange="this.form.submit()">

<option value="" selected="selected" disabled="disabled"> --- Select a page --- </option>

<option value="http://www.kompx.com/en/os/linux-1.htm">Linux</option>

<option value="http://www.kompx.com/en/os/windows-1.htm">Windows</option>

<option value="http://www.kompx.com/en/os/dos-1.htm">DOS</option>

</select>

<noscript><input type="submit" value="Submit" /></noscript>

</form>

When an option has been chosen from the dropdown list, the form's state is changed. So the onchange event occurs and JavaScript code in onchange is executed: the process of the form submission in started by the script, not by clicking submit button which is absent.

Some server-side script [ 3 ] is meant then to handle the form action. The script is supposed to get what the form sends and have it processed. A PHP script in action.php is used in the example:

<?php

if (isset($_POST["page"])) {

    header("Location: $_POST[page]");

    exit;

} else {

    echo "No options selected";

}

$_POST is an array of variables passed to the current script via the HTTP POST method. So $_POST[page] contains the content of the value attribute in a select option. That is, a URL. It is passed from form to PHP script and the script redirects browser to the URL / page selected.

HTML code of <noscript><input type="submit" value="Submit" /></noscript> is present in the form as a fallback in case JavaScript happens to be turned off. Then there is a submit button to appear and the form is usable anyway.


[ 1 ]

As well as Netscape 3.04+, Mozilla 0.6+.

[ 2 ]

As well as Netscape 3.04+, Mozilla 0.6+.

[ 3 ]

If a CMS is used, form action may be handled by some of its inbuilt means.


Aliosque subditos et thema

 

CSS horizontal and vertical centering - 1

 

Centering the content of a web page in the viewable area of a browser by means of CSS. A box to contain the whole content of the page is CSS centered horizontally and vertically: [ Open demo page ] HTML / XHTML. Code: <!DOCTYPE html> <html> <head> <title>CSS horizontal and vertical centering - 1</title> <link rel="stylesheet" type="text/css" href="css.css" /> </head> <body> <div class="all"> <div class="wrapper"> <div class="pagecontent">&nbsp;</div> </div> </div> </body> </html> CSS. Code: html {height: 100%; margin: 0px;} body height: 100%; margin: 0px;} .all {position: relative; left: 0px; top: 0px; height: 100%; width: 100%; float: left; display: table;} .wrapper {position: relative; left: 0px; top: 0px; height: auto; width: 100%; display: table-cell; vertical-align: middle;} .pagecontent {position: relative; left: 0px; top: 0px; height: 500px; width: 800px; margin: 0 auto; background: #ff6f6f;} The .pagecontent box is for the page content. It may be of height assigned explicitly or just "height: auto". Unlike CSS horizontal and vertical centering - 2, here percents may also be used as CSS units; not just px's or em's. Height and width may be larger than web browser viewable area, but here the more practical case is discussed - when the height and width of .pagecontent are smaller than those of the web browser viewable area. The .pagecontent box is horizontally centered by its "margin: 0 auto". .All with its CSS properties makes the whole web browser viewable area into a CSS table. CSS properties makes .wrapper into the cell of this CSS table. The content of this CSS table cell - the .pagecontent box with everything inside it - is vertically centered in the viewable area of a browser by "vertical-align: middle". [ 1 ] As well as Netscape 7.2+, Mozilla 1.5+. [ 2 ] As well as Netscape 7.2+, Mozilla 1.5+.

Renaming folders in mc

 

Renaming a folder in mc / Midnight Commander: - Select a folder --> Shift - F6 --> Edit existing folder name into a new one --> Enter Select a folder Edit folder name The original way of renaming a folder - the one mc / Midnight Commander had before "Shift - F6" was implemented - is also still there: - Select a folder --> F6 --> Enter a new folder name --> Enter Select a folder Enter folder name And "Esc - 6" may be used instead of "F6": - Select a file --> Esc - 6 --> Enter a new folder name --> Enter Select a folder Enter folder name