host

Property. A string specifying the server name, sub-domain, and domain name.

Syntax

server.host

Property of

server

Description

The host property specifies a portion of a URL. The host property is a substring of the hostname property. The hostname property is the concatenation of the host and port properties, separated by a colon. When the port property is 80 (the default), the host property is the same as the hostname property.

host is a read-only property.

See Section 3.1 of RFC 1738 (http://www.cis.ohio-state.edu/htbin/rfc/rfc1738.html) for complete information about the hostname and port.

Examples

See the examples for the server object.

See also

hostname, port, and protocol properties

hostname

Property. A string containing the full hostname of the server, including the server name, sub-domain, domain, and port number.

Syntax

server.hostname

Property of

server

Description

The hostname property specifies a portion of a URL. The hostname property is the concatenation of the host and port properties, separated by a colon. When the port property is 80 (the default), the host property is the same as the hostname property.

hostname is a read-only property.

See Section 3.1 of RFC 1738 (http://www.cis.ohio-state.edu/htbin/rfc/rfc1738.html) for complete information about the hostname and port.

Examples

See the examples for the server object.

See also

host, port, and protocol properties

indexOf

Method. Returns the index within the calling string object of the first occurrence of the specified value, starting the search at fromIndex.

Syntax

stringName.indexOf(searchValue, [fromIndex])

Parameters

stringName is any string or a property of an existing object.

searchValue is a string or a property of an existing object, representing the value to search for.

fromIndex is the location within the calling string to start the search from. It can be any integer from 0 to stringName.length - 1 or a property of an existing object.

Method of

string

Description

Characters in a string are indexed from left to right. The index of the first character is 0, and the index of the last character is stringName.length - 1.

If you do not specify a value for fromIndex, JavaScript assumes 0 by default. If searchValue is not found, JavaScript returns -1.

Examples

The following example uses indexOf and lastIndexOf to locate values in the string "Brave new world".

var anyString="Brave new world"

//Displays 8
document.write("<P>The index of the first w from the beginning is " +
   anyString.indexOf("w"))
//Displays 10
document.write("<P>The index of the first w from the end is " +
   anyString.lastIndexOf("w"))
//Displays 6
document.write("<P>The index of 'new' from the beginning is " +
   anyString.indexOf("new"))
//Displays 6
document.write("<P>The index of 'new' from the end is " +
   anyString.lastIndexOf("new"))

See also

charAt, lastIndexOf methods

inputName

Property. Represents an input element on an HTML form.

Syntax

request.inputName

Parameters

inputName is the value of the name property of an input element on an HTML form.

Property of

request

Description

Each input element in an HTML form corresponds to a property of the request object. The name of each of these properties is the name of the field on the associated form. inputName is a variable that represents the value of the name property of an input field on a submitted form. By default, the value of the JavaScript name property is the same as the HTML NAME attribute.

inputName is a read-only property.

Examples

The following HTML source creates the request.lastName and the request.firstName properties when the idForm is submitted:

<FORM METHOD="post" NAME="idForm" ACTION="hello.html">
<P>Last name:
	<INPUT TYPE="text" NAME="lastName" SIZE="20">
<BR>First name:
	<INPUT TYPE="text" NAME="firstName" SIZE="20">
</FORM>

insertRow

Method. Inserts a row in a database table.

Syntax

cursorName.insertRow("tableName")

Parameters

cursorName is the name of a cursor object.

tableName is the name of a database table.

Method of

cursor

Description

The insertRow method uses an updateable cursor to insert a row in the specified table. The inserted row follows the current row. See the cursor method for information about creating an updateable cursor.

You can specify values for the row you are inserting as follows:

The insertRow method inserts a null value in any table columns that do not appear in the cursor.

The insertRow method returns a status code based on a database server message to indicate whether the method completed successfully. If successful, the method returns a 0; otherwise, it returns a non-zero integer to indicate the reason it failed. See Interpreting Database Status Codes for an explanation of the individual status codes.

Examples

In some applications, such as a video rental application, a husband, wife, and children could all share the same account number but be listed under different names. In this example, a user has just added a name to the accounts table and wants to add a spouse's name to the same account.

customerSet = database.cursor("select * from customer", true)

x=true
while (x) {
   x = customerSet.next() }

customerSet.name = request.theName
customerSet.insertRow("accounts")
customerSet.close()
In the above example, the next method navigates to the last row in the table, which contains the most recently added account. The value of theName is passed in by the request object and assigned to the name column in the customerSet cursor. The insertRow method inserts a new row at the end of the table. The value of the name column in the new row is the value of theName. Because the application used the next method to navigate, the value of every other column in the new row is the same as the value in the previous row.

See also

deleteRow and updateRow methods

ip

Property. Provides the IP address of the client.

Syntax

request.ip

Property of

request

Description

The IP address is a set of four numbers between 0 and 255, for example, "198.217.226.34". You can use the IP address to authorize or record access in certain situations.

ip is a read-only property.

Examples

In the following example, the indexOf method evaluates request.ip to determine if it begins with the string "198.217.226.". The if statement executes a different function depending on the result of the indexOf method.

<SERVER>
var ipAddress=request.ip
if (ipAddress.indexOf("198.217.226.")==-1)
	limitedAccess()
else
	fullAccess()
</SERVER>

See also

agent, method, and protocol properties

isNaN

Function. On Unix platforms, evaluates an argument to determine if it is "NaN" (not a number).

Syntax

isNaN(testValue)

Parameters

testValue is the value you want to evaluate.

Description

The isNaN function is a built-in JavaScript function. It is not a method associated with any object, but is part of the language itself. isNaN is available on Unix platforms only.

On all platforms except Windows, the parseFloat and parseInt functions return "NaN" when they evaluate a value that is not a number. The "NaN" value is not a number in any radix. You can call the isNaN function to determine if the result of parseFloat or parseInt is "NaN". If "NaN" is passed on to arithmetic operations, the operation results will also be "NaN".

The isNaN function returns true or false.

Examples

The following example evaluates floatValue to determine if it is a number, then calls a procedure accordingly.

floatValue=parseFloat(toFloat)

if isNaN(floatValue) {
   notFloat()
} else {
   isFloat()
}

See also

parseFloat, parseInt functions

italics

Method. Causes a string to be italicized as if it were in an <I> tag.

Syntax

stringName.italics()

Parameters

stringName is any string or a property of an existing object.

Method of

string

Description

Use the italics method with the write or writeln methods to format and display a string in a document.

Examples

The following example uses string methods to change the formatting of a string:

var worldString="Hello, world"

document.write(worldString.blink())
document.write("<P>" + worldString.bold())
document.write("<P>" + worldString.italics())
document.write("<P>" + worldString.strike())
The previous example produces the same output as the following HTML:

<BLINK>Hello, world</BLINK>
<P><B>Hello, world</B>
<P><I>Hello, world</I>
<P><STRIKE>Hello, world</STRIKE>

See also

blink, bold, strike methods

lastIndexOf

Method. Returns the index within the calling string object of the last occurrence of the specified value. The calling string is searched backwards, starting at fromIndex.

Syntax

stringName.lastIndexOf(searchValue, [fromIndex])

Parameters

stringName is any string or a property of an existing object.

searchValue is a string or a property of an existing object, representing the value to search for.

fromIndex is the location within the calling string to start the search from. It can be any integer from 0 to stringName.length - 1 or a property of an existing object.

Method of

string

Description

Characters in a string are indexed from left to right. The index of the first character is 0, and the index of the last character is stringName.length - 1.

If you do not specify a value for fromIndex, JavaScript assumes stringName.length - 1 (the end of the string) by default. If searchValue is not found, JavaScript returns -1.

Examples

The following example uses indexOf and lastIndexOf to locate values in the string "Brave new world".

var anyString="Brave new world"

//Displays 8
document.write("<P>The index of the first w from the beginning is " +
   anyString.indexOf("w"))
//Displays 10
document.write("<P>The index of the first w from the end is " +
   anyString.lastIndexOf("w"))
//Displays 6
document.write("<P>The index of 'new' from the beginning is " +
   anyString.indexOf("new"))
//Displays 6
document.write("<P>The index of 'new' from the end is " +
   anyString.lastIndexOf("new"))

See also

charAt, indexOf methods

length

Property. An integer that specifies a length-related feature of the calling object or array.

Syntax

When used with objects:

1. formName.length
2. frameReference.length
3. history.length
4. radioName.length
5. selectName.length
6. stringName.length
7. windowReference.length
When used with array properties:

8. anchors.length
9. arguments.length
10. elements.length
11. forms.length
12. frameReference.frames.length
13. windowReference.frames.length
14. links.length
15. selectName.options.length

Parameters

formName is either the name of a form or an element in the forms array.

frameReference is either the value of the NAME attribute of a frame or an element in the frames array.

radioName is either the value of the NAME attribute of a radio object or an element in the elements array.

selectName is either the value of the NAME attribute of a select object or an element in the elements array.

stringName is any string or a property of an existing object.

windowReference is a valid way of referring to a window, as described in the window object.

Property of

  • frame object, history object, radio object, select object, string object, window object
  • anchors array, arguments array, elements array, forms array, frames array, links array, options array (see select object)

    Description

    The length property is an integer that specifies one of the following:

  • The number of elements on a form (form 1 of the syntax).
  • The number of frames within a frame (form 2 of the syntax). A frame that does not load a document containing a <FRAMESET> tag always has a length of 0.
  • The number of entries in a history object (form 3 of the syntax).
  • The number of radio buttons in a radio object (form 4 of the syntax).
  • The number of options in a select object (form 5 of the syntax).
  • The length of a string object (form 6 of the syntax).
  • The number of frames in a parent window (form 7 of the syntax).
  • The number of entries in one of the array properties (all other syntax forms). length is always a read-only property.

    For a null string, length is zero. For a select object, the values returned by form 5 and form 15 of the syntax are the same. For a window containing frames, the values returned by form 7 and form 13 of the syntax are the same. For a form object, the values returned by form 1 and form 10 of the syntax are the same. For a frame containing frames, the values returned by form 2 and form 12 of the syntax are the same.

    Examples

    In the following example, the getChoice() function uses the length property to iterate over every element in the musicType array. musicType is a select element on the musicForm form.

    function getChoice() {
       for (var i = 0; i < document.musicForm.musicType.length; i++) {
          if (document.musicForm.musicType.options[i].selected == true) {
             return document.musicForm.musicType.options[i].text
          }
       }
    }
    
    The following example displays 8 in an alert dialog box:

    var x="Netscape"
    alert("The string length is " + x.length)
    

    link method

    Method. Creates an HTML hypertext link that jumps to another URL.

    Syntax

    linkText.link(hrefAttribute)
    

    Parameters

    linkText is any string or a property of an existing object.

    hrefAttribute is any string or a property of an existing object.

    Method of

    string

    Description

    Use the link method with the write or writeln methods to programmatically create and display a hypertext link in a document. Create the link with the link method, then call write or writeln to display the link in a document.

    In the syntax, the linkText string represents the literal text that you want the user to see. The hrefAttribute string represents the HREF attribute of the <A> tag, and it should be a valid URL. Each section of a URL contains different information. See the location object for a description of the URL components.

    Links created with the link method become elements in the links array. See the link object for information about the links array.

    Examples

    The following example displays the word "Netscape" as a hypertext link that returns the user to the Netscape home page:

    var hotText="Netscape"
    var URL="http://www.netscape.com"
    
    document.open()
    document.write("Click to return to " + hotText.link(URL))
    document.close()
    
    The previous example produces the same output as the following HTML:

    Click to return to <A HREF="http://www.netscape.com">Netscape</A>
    

    See also

    anchor object

    LN2

    Property. The natural logarithm of two, approximately 0.693.

    Syntax

    Math.LN2
    

    Property of

    Math

    Description

    Because LN2 is a constant, it is a read-only property of Math.

    Examples

    The following example displays the natural log of 2:

    document.write("The natural log of 2 is " + Math.LN2)
    

    See also

    E, LN10, LOG2E, LOG10E, PI, SQRT1_2, SQRT2 properties

    LN10

    Property. The natural logarithm of ten, approximately 2.302.

    Syntax

    Math.LN10
    

    Property of

    Math

    Description

    Because LN10 is a constant, it is a read-only property of Math.

    Examples

    The following example displays the natural log of 10:

    document.write("The natural log of 10 is " + Math.LN10)
    

    See also

    E, LN2, LOG2E, LOG10E, PI, SQRT1_2, SQRT2 properties

    lock

    Method. Locks the project or server object to prevent other clients from modifying or locking it.

    Syntax

    1. project.lock()
    2. server.lock()
    

    Method of

    project, server

    Description

    You can lock the project or server object to ensure that different clients do not change its properties simultaneously. When an application locks an object, other client requests must wait before they can modify or lock the object.

    It is good programming practice to call the unlock method and release the an object after calling the lock method. However, LiveWire automatically unlocks an object after the completion of each request to prevent an accidental deadlock situation.

    Examples

    See Example 2 of the project object for an example of using the lock method.

    See also

    unlock method

    log

    Method. Returns the natural logarithm (base e) of a number.

    Syntax

    Math.log(number)
    

    Parameters

    number is any positive numeric expression or a property of an existing object.

    Method of

    Math

    Description

    If the value of number is outside the suggested range, the return value is always -1.797693134862316e+308.

    Examples

    //Displays the value 2.302585092994046
    document.write("The natural log of 10 is " + Math.log(10))
    
    //Displays the value 0
    document.write("<P>The natural log of 1 is " + Math.log(1))
    
    //Displays the value -1.797693134862316e+308
    //because the argument is out of range
    document.write("<P>The natural log of 0 is " + Math.log(0))
    

    See also

    exp, pow methods

    LOG2E

    Property. The base 2 logarithm of e (approximately 1.442).

    Syntax

    Math.LOG2E
    

    Property of

    Math

    Description

    Because LOG2E is a constant, it is a read-only property of Math.

    Examples

    The following example displays the base 2 logarithm of E:

    document.write("The base 2 logarithm of E is " + Math.LOG2E)
    

    See also

    E, LN2, LN10, LOG10E, PI, SQRT1_2, SQRT2 properties

    LOG10E

    Property. The base 10 logarithm of e (approximately 0.434).

    Syntax

    Math.LOG10E
    

    Property of

    Math

    Description

    Because LOG10E is a constant, it is a read-only property of Math.

    Examples

    The following example displays the base 10 logarithm of E:

    document.write("The base 10 logarithm of E is " + Math.LOG10E)
    

    See also

    E, LN2, LN10, LOG2E, PI, SQRT1_2, SQRT2 properties