The script.aculo.us library is a cross-browser library that aims at improving the user interface of a website. The Ajax.InPlaceEditor is used to make elements editable thereby allowing the user to edit the content on the page and submit the changes to the server.
The InPlaceEditor cols option is used to specify the number of columns to be shown in the InPlaceEditor. This property works for both single and multiline area input.
Syntax:
{ cols: value }
Parameters: This option has a single value as mentioned above and described below:
- value: This is a number that is used to specify the number of columns to be shown in the editor.
The below example illustrates the use of this option.
Example:
The below script is required to simulate the saving of data to the server.
PHP
<?php if ( isset( $_REQUEST [ "value" ]) ) { $str = $_REQUEST [ "value" ]; echo $str ; } ?> |
The below script demonstrates this with the example:
HTML
< html > < head > < script type="text/javascript " src = "prototype.js" > </ script > < script type = "text/javascript" src = "scriptaculous.js?load = controls" > </ script > < script type = "text/javascript" > window.onload = function () { // Default InplaceEditor with no // options new Ajax.InPlaceEditor( 'editableElement', ); // InplaceEditor with the cols // option changed to a custom value new Ajax.InPlaceEditor( 'editableElement2', { // Specify the number of columns // to be used in the InplaceEditor cols: 5 } ); // InplaceEditor with the cols // option changed to a custom value new Ajax.InPlaceEditor( 'editableElement3', { // Specify the number of columns // to be used in the InplaceEditor cols: 60 } ); } </ script > </ head > < body > < h1 style = "color: green" > neveropen </ h1 > < h2 >InPlaceEditor cols Option</ h2 > < p >The "cols" option is used to specify the number of columns to be used in the InPlaceEditor.</ p > < b >This element has the cols as the default value.</ b > < div id = "editableElement" >Click to edit</ div > < br > < b >This element has the cols set to 5.</ b > < div id = "editableElement2" >Click to edit</ div > < br > < b >This element has the cols set to 60.</ b > < div id = "editableElement3" > Click to edit multiline </ div > </ body > </ html > |
Output: