I need to split the area code out of the () so it only displays numbers using the substring method. Below is the code I have done so car.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>No Title</title>
<script type = "text/javascript">
function splitButtonPressed()
	var inputString = document.getElementById( "inputVal").value;
	var mySplitResult = inputString.split(" ");
	document.getElementByID("area").value = mySplitResult[0].substring(1,3);
	document.getElementById("number").value = mySplitResult[1];	
// -->

<h1> Lab Excerise</h1>
<form action = "">
<table width="600" border="2" cellspacing="1" cellpadding="1">
    <td>Enter a phone number [in the form (555) 555-5555] </td>
    <td><input id = "inputVal" type = "text" /></td>
    <td><input type = "button" value = "Split" onclick = "splitButtonPressed()" /> </td>
    <td>Area code:</td>
    <td><input id = "area" type = "text" size = "15" /></td>
    <td>Number: </td>
    <td><input id = "number" type = "text" size = "15" /></td>


The error is in the below line

document.getElementByID("area").value = mySplitResult[0].substring(1,3)

because if i delete the rest after [0] then it prints perfect but displays the () with the area code and that's not what I need.


Are you using FireBug to debug your code? If not you should use. What is the error that you get? "document.getElementByID is not a function" Look much closer to what you wrote. :P

Umh, use regex

inputString = inputString.replace(/[^0-9]/g,'')


i think ...macneato... provide information is best and he solved your problem.