Showing posts with label HTML. Show all posts
Showing posts with label HTML. Show all posts

Tuesday, February 19, 2013

Saturday, October 6, 2012

Javascript: getting selected item


Html:

<select id="estadosiniciales">
                    <option value ="sydney">Sydney</option>
                    <option value ="melbourne">Melbourne</option>
                    <option value ="cromwell" selected>Cromwell</option>
                    <option value ="queenstown">Queenstown</option>
</select>

Javascript:


var selectIni = document.getElementById("estadosiniciales");      
alert(selectIni.options[selectIni.selectedIndex].text);


Resources:
http://www.java2s.com/Tutorial/JavaScript/0200__Form/Findtheselectedoption.htm

Javascript: adding options to select dynamically

Your html:


<select id="estadosiniciales">
                    <option value ="sydney">Sydney</option>
                    <option value ="melbourne">Melbourne</option>
                    <option value ="cromwell" selected>Cromwell</option>
                    <option value ="queenstown">Queenstown</option>
</select>

Your Javascript:


var newOption = new Option("newStateName","newStateName");
var selectIni = $("#estadosiniciales"); // using Jquery
selectIni.append(newOption)


Resources:
http://www.devguru.com/technologies/ecmascript/quickref/option.html
http://stackoverflow.com/questions/4647863/trouble-dynamically-adding-options-to-select

Monday, July 23, 2012

Simple WYSIWYG HTML Editor Sample

the file structure of the project is:

./project
./project/myWYSIWYGTest.html --- here is the source code of the example
./project/ckeditor --source code of the ckeditor lib, download where http://ckeditor.com/download

the code of the myWYSIWYGTest html page is:

<html>
    <head>
        <script type="text/javascript" src="./ckeditor/ckeditor.js">
        </script>
    </head>
    <body>
        <textarea class="ckeditor" name="editor1"></textarea>
    </body>
</html>

Reference:
http://nightly.ckeditor.com/7582/_samples/replacebyclass.html

Saturday, July 14, 2012

HTML: Simple Table

Using <Table> tag:

<table border="1">
<tr>
<td>row 1, cell 1</td>
<td>row 1, cell 2</td>
</tr>
<tr>
<td>row 2, cell 1</td>
<td>row 2, cell 2</td>
</tr>
</table>


Result:


row 1, cell 1 row 1, cell 2
row 2, cell 1 row 2, cell 2


Resource:
http://www.w3schools.com/html/html_tables.asp