Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is Null or Not an Object

Status
Not open for further replies.

awieland

Programmer
Apr 18, 2005
36
US
I am receiving a JavaScript error and not able to send my varible to the database. The code that is giving me trouble is . Please know that I am using XML and the code sits in an XML template called W4Page and in that XML template the form W4Form is being used. I apologize for the large post, but I thought if someone sees the entire XML template it would help. Thank You.

Javascript error:

'document.W4Form.MarriedFileSingle' is null or not an object

My Code (which includes the entire XML template):

<xsl:template match="W4Page">

<script type="text/javascript">_page.startPage(PAY)</script>

<script LANGUAGE="JavaScript">

function StateW4Select(State)
{

//These State require a generic W4 form in addition to one particular for their state.
GenericStates = "DE,NE";

if(document.W4Form.W4.selectedIndex == 0) {
return false;
}

page = "forms/StateW4/" + State.value + ".pdf"
window.open(page,"StateW4");

}

function disable(InputField) {
InputField.disabled=1;
}

var state;
</script>

<FORM action="W4Router" method="Post" name="W4Form">

<TABLE border="0" cellpadding="0" cellspacing="0" width="635">
<TR>
<TD>
<xsl:text disable-output-escaping="yes">&amp;nbsp;&amp;nbsp;</xsl:text>
</TD>
<TD>
<TABLE border="0" cellpadding="1" cellspacing="0" align="left" width="615">
<TR valign="top">
<TD align="right">
<TABLE align="right" border="0" cellpadding="0" cellspacing="0">
<TR>
<TD>
<a href="javaScript:window.openTextPage('html/USA/Eng/help/W4_help.html');" align="right"><IMG SRC="images/help.gif" align="right" BORDER="0" ALT="Help" /></a>
</TD>
</TR>
</TABLE>
</TD>
</TR>
<!-- <TR valign="top">
<TD align="left">

<P class="groupheading">My Pay</P>
</TD>
</TR> -->
<!-- ARW added main image on 7/1/04 -->
<TR valign="top">
<TD align="left">
<br/>
<IMG SRC="images/philips/mainvisual_w4.jpg" BORDER="0"/>
</TD>
</TR>
<!-- ARW added main image on 7/1/04 -->
<TR>
<TD class="standard">
<br/>

A W-4 enables you to indicate the amount of federal income tax to be withheld from your pay. The withholding amount is based on your marital status, number of dependents, and any additional tax withholding you may request. IRS regulation does not allow you to claim more than 10 allowances without approval. You cannot elect to have a flat dollar ($) or flat percentage (%) withheld from your pay. <br/><br/>

The information below reflects your current W-4 withholding. You can change your W-4 withholding by making changes to the fields below and clicking on the Save button. Your changes will be reflected on the next available payroll. <br/><br/>

To print a state W-4 form, select the state from the drop-down below and click on the View State W-4 button. Please fax the completed form to the PACE Service Center. Fax (561)244-0929.
<!--
<xsl:choose>
<xsl:when test="contains(LockStatus, 'Y')">
To update your Federal W-4, please submit a completed W-4 form to the PACE Service Center. Fax (561)244-0929.
</xsl:when>
<xsl:eek:therwise>
You can change your W-4 withholding by making changes to the fields below and clicking on the Save button.
</xsl:eek:therwise>
</xsl:choose>
-->
<p>
<xsl:for-each select="StatusMessage">
<!-- populate the status messages one at a time -->
<xsl:for-each select="StatusMsg">
<font face="Lucia Sans Unicode, Arial, Helvetica" size="2" color="red"><b><xsl:value-of select="." /></b></font><br/>
</xsl:for-each>
</xsl:for-each>
</p>

</TD>
</TR>
<TR height="25">
<TD valign="bottom" height="25">
<TABLE border="0">
<TR>
<TD>
<SELECT name="W4" SELECTED-BY="VALUE" onchange="javascript:state=this">
<OPTION selected="yes" value="BLANK">Select One...</OPTION>
<OPTION value="AL">Alabama</OPTION>
<OPTION value="AR">Arkansas</OPTION>
<OPTION value="AZ">Arizona</OPTION>
<OPTION value="CA">California</OPTION>
<OPTION value="CO">Colorado</OPTION>
<OPTION value="CT">Connecticut</OPTION>
<OPTION value="DC">District of Columbia</OPTION>
<OPTION value="DE">Delaware</OPTION>
<OPTION value="GA">Georgia</OPTION>
<OPTION value="HI">Hawaii</OPTION>
<OPTION value="IA">Iowa</OPTION>
<OPTION value="ID">Idaho</OPTION>
<OPTION value="IL">Illinois</OPTION>
<OPTION value="IN">Indiana</OPTION>
<OPTION value="KS">Kansas</OPTION>
<OPTION value="KY">Kentucky</OPTION>
<OPTION value="LA">Louisiana</OPTION>
<OPTION value="MA">Massachusetts</OPTION>
<OPTION value="MD">Maryland</OPTION>
<OPTION value="ME">Maine</OPTION>
<OPTION value="MI">Michigan</OPTION>
<OPTION value="MN">Minnesota</OPTION>
<OPTION value="MO">Missouri</OPTION>
<OPTION value="MS">Mississippi</OPTION>
<OPTION value="MT">Montana</OPTION>
<OPTION value="NC">North Carolina</OPTION>
<OPTION value="ND">North Dakota</OPTION>
<OPTION value="NE">Nebraska</OPTION>
<OPTION value="NJ">New Jersey</OPTION>
<OPTION value="NM">New Mexico</OPTION>
<OPTION value="NY">New York</OPTION>
<OPTION value="OH">Ohio</OPTION>
<OPTION value="OK">Oklahoma</OPTION>
<OPTION value="OR">Oregon</OPTION>
<OPTION value="RI">Rhode Island</OPTION>
<OPTION value="SC">South Carolina</OPTION>
<OPTION value="UT">Utah</OPTION>
<OPTION value="VA">Virginia</OPTION>
<OPTION value="VT">Vermont</OPTION>
<OPTION value="WI">Wisconsin</OPTION>
<OPTION value="WV">West Virginia</OPTION>
<OPTION value="PR">Puerto Rico</OPTION>
</SELECT>
<xsl:text disable-output-escaping="yes">&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;</xsl:text>
<!-- ARW 7/16/04 adjusted class="button1" -->
<INPUT type="button" class="button4" value="View State W-4" onclick="StateW4Select(state)" />
</TD>
<TD>

<xsl:text disable-output-escaping="yes">&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;</xsl:text>
<xsl:text disable-output-escaping="yes">&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;</xsl:text>
<xsl:text disable-output-escaping="yes">&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;</xsl:text>
<xsl:text disable-output-escaping="yes">&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;</xsl:text>

<A href=" target="_child" ><IMG align="bottom" src="images\getacro.gif" border="0" ></IMG></A>
</TD>
</TR>
</TABLE>
</TD>
</TR>
<TR>
<TD align="left">
<P class="pageheading">W-4 Information</P>
<br/>
</TD>
</TR>
<TR>
<TD>
<TABLE border="0" cellpadding="0" cellspacing="0" width="450" >

<TR class="standard">
<TD align="left" class="ColHeadingLm" height="26">Name: </TD>
<TD class="standard" height="26">
<!-- extract the first name from the full name -->
<xsl:variable name="Name"><xsl:value-of select="FullName"/></xsl:variable>

<xsl:variable name="NewName">
<xsl:value-of select="substring-after($Name, ',')"/>
<xsl:text> </xsl:text>
<xsl:value-of select="substring-before($Name, ',')"/>
</xsl:variable>
<xsl:value-of select="$NewName"/>
</TD>
</TR>
<!-- remove SSN
<TR class="standardLt">
<TD align="left" class="ColHeadingLm" height="26">Social Security Number: </TD>
<TD class="standard" height="26"><xsl:value-of select="SSN" /></TD>
</TR>
-->

<TR class="standardLt2">
<TD align="left" class="ColHeadingLm" height="26">Home Address: </TD>
<TD class="standard" height="26"><xsl:value-of select="Street1"/><xsl:if test ="(string-length(Street2))>0"><br/><xsl:value-of select="Street2"/></xsl:if><br/><xsl:value-of select="City"/>, <xsl:value-of select="State"/>
<xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text><xsl:choose><xsl:when test="(string-length(Postal)) = 9"><xsl:value-of select="substring(Postal,1,5)" />-<xsl:value-of select="substring(Postal,6,4)" /></xsl:when><xsl:eek:therwise><xsl:value-of select="Postal"/></xsl:eek:therwise></xsl:choose></TD>
</TR>

<TR class="standardLt">
<TD align="left" class="ColHeadingLm" height="26">Work State: </TD>
<TD class="standard" height="26"><xsl:value-of select="WorkState" /></TD>
</TR>
<TR class="standardLt2">
<TD align="left" class="ColHeadingLm" height="26">Filing Status: </TD>
<TD class="standard" height="26" >
<xsl:choose>
<xsl:when test="contains(FilingStatus, 'S')" >
<SCRIPT LANGUAGE="JavaScript">
var filingStatus = "S";

</SCRIPT>
<INPUT type="radio" name="FilingStatus" checked="yes" value="S" onclick="javascript:filingStatus='S'" />Single
<INPUT type="radio" name="FilingStatus" value="M" onclick="javascript:filingStatus='M'" />Married
<INPUT type="radio" name="FilingStatus" value="E" onclick="javascript:filingStatus='E'" />Exempt
</xsl:when>

<xsl:when test="contains(FilingStatus, 'M')" >
<SCRIPT LANGUAGE="JavaScript">
var filingStatus = "M";
</SCRIPT>
<INPUT type="radio" name="FilingStatus" value="S" onclick="javascript:filingStatus='S'" />Single
<INPUT type="radio" name="FilingStatus" checked="yes" value="M" onclick="javascript:filingStatus='M'" />Married
<INPUT type="radio" name="FilingStatus" value="E" onclick="javascript:filingStatus='E'" />Exempt
</xsl:when>

<xsl:when test="contains(FilingStatus, 'E')" >
<SCRIPT LANGUAGE="JavaScript">
var filingStatus = "E";
</SCRIPT>
<INPUT type="radio" name="FilingStatus" value="S" onclick="javascript:filingStatus='S'" />Single
<INPUT type="radio" name="FilingStatus" value="M" onclick="javascript:filingStatus='M'" />Married
<INPUT type="radio" name="FilingStatus" checked="yes" value="E" onclick="javascript:filingStatus='E'" />Exempt
</xsl:when>

<xsl:eek:therwise>
<SCRIPT LANGUAGE="JavaScript">
var filingStatus = "";
</SCRIPT>
<INPUT type="radio" name="FilingStatus" value="S" onclick="javascript:filingStatus='S'" />Single
<INPUT type="radio" name="FilingStatus" value="M" onclick="javascript:filingStatus='M'" />Married
<INPUT type="radio" name="FilingStatus" value="E" onclick="javascript:filingStatus='E'" />Exempt
</xsl:eek:therwise>
</xsl:choose>
<nobr/><IMG border="0" src="images\required.gif" width="12" height="12"/>
</TD>
</TR>

<!-- ARW 3/25/05 SR 1-6103943 Added Married File Single Check Box -->

<TR class="standardLt2">
<TD align="left" class="ColHeadingLm" height="26"></TD>
<TD class="standard" height="26">If married, but withholding at single rate, select Single status and select Yes.</TD>
</TR>

<TR class="standardLt2">
<TD align="left" class="ColHeadingLm" height="26"></TD>

<TD class="standard" height="26">
<xsl:choose>
<xsl:when test="(MarriedFileSingle)='Y'">
<INPUT type="checkbox" name="fMarriedFileSingle" onClick="javascript:marriedSingle()" checked="yes" value="Y"></INPUT>
</xsl:when>
<xsl:eek:therwise>
<INPUT type="checkbox" name="fMarriedFileSingle" onClick="javascript:marriedSingle()" value="N"></INPUT>
</xsl:eek:therwise>
</xsl:choose>
</TD>


</TR>

<TR class="standardLt">
<TD align="left" class="ColHeadingLm" height="26">Total No. of Allowance: </TD>
<TD class="standard" height="26">

<xsl:choose>
<xsl:when test ="string-length(FedAllowances)=0">
<INPUT type="text" name="TotalAllowances" size="2" maxlength="2" value="0" />
</xsl:when>
<xsl:eek:therwise>
<INPUT type="text" name="TotalAllowances" size="2" value="{FedAllowances}" />
</xsl:eek:therwise>
</xsl:choose>

<IMG border="0" src="images\required.gif" width="12" height="12"/><xsl:text> </xsl:text>
<xsl:text disable-output-escaping="yes">&amp;nbsp;&amp;nbsp;</xsl:text><A href="W4Router?Funct_W4_ALLOWANCESBLANK=Allowances_Blank"><u>Worksheet</u></A>
</TD>
</TR>
<TR class="standardLt2">
<TD align="left" class="ColHeadingLm" height="26">Additional Amount Withheld From Each Paycheck: </TD>
<TD class="standard" height="26">

<SELECT name="WithholdingType">
<xsl:choose>
<xsl:when test="contains(WithholdingType, 'dollar')">
<OPTION value="percent" >%</OPTION>
<OPTION value="dollar" selected="yes">$</OPTION>
</xsl:when>
<xsl:eek:therwise>
<OPTION value="percent" selected="yes">%</OPTION>
<OPTION value="dollar" >$</OPTION>
</xsl:eek:therwise>
</xsl:choose>
</SELECT>

<INPUT type="text" name="WithholdingAmount" size="4" maxlength="4" value="{WithholdingAmount}"/>

</TD>
</TR>

<TR>
<TD colspan="2">
<xsl:text disable-output-escaping="yes">&amp;nbsp;&amp;nbsp;</xsl:text>
</TD>
</TR>
<TR>
<TD class="standardRequired" colspan="2"><br/>Required fields are marked by<IMG border="0" src="images\required.gif" width="12" height="12"/><br/></TD>
</TR>
<TR>
<TD colspan="2">
<TABLE border="0" width="380" align="center">
<TR>
<TD align="right">
<!-- ARW 7/16/04 adjusted class="button1" -->
<INPUT type="submit" name="Funct_W4_UPDATE" value="Save" class="button3" onclick="javascript:UpdateW4();" />

</TD>
<TD></TD>
<TD align="left">
<!-- ARW 7/16/04 adjusted class="button1" -->
<INPUT type="button" name="Reset_Button" value="Reset" class="button3" onclick="javascript:document.W4Form.reset();"/>
</TD>
</TR>
</TABLE>
</TD>
</TR>

<TR>
<TD colspan="2" height="10" align="center" class="copyRight">
Copyright Philips <xsl:text disable-output-escaping="yes">&amp;copy</xsl:text> 2005
</TD>
</TR>
</TABLE>

</TD>
</TR>
</TABLE>
</TD>
</TR>
<TR>
<TD colspan="2"><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/></TD>
</TR>
</TABLE>
</FORM>

<FORM name="categoryForm">
<INPUT type="hidden" nme="category" value="pay"/>
</FORM>

<!-- ARW 3/28/05 SR 1-6103943 Added MarriedFileSingle to form on -->

<FORM name="updateW4Form" action="W4Router?Funct_W4_UPDATE=Update">
<INPUT type="hidden" name="FilingStatus" value=" "/>
<INPUT type="hidden" name="MarriedFileSingle" value=" " />
<INPUT type="hidden" name="WithholdingType" value=" "/>
<INPUT type="hidden" name="TotalAllowances" value=" " />
<INPUT type="hidden" name="WithholdingAmount" value=" "/>
<INPUT type="hidden" name="Funct_W4_UPDATE" value="Update"/>
</FORM>


<script LANGUAGE="JavaScript">


var strUrlW4 = document.URL;

var startIndex = strUrlW4.lastIndexOf('DATA1=');
if (startIndex>0){
var strAllowance = strUrlW4.substr(startIndex+6);
document.W4Form.totalAllowances.value = strAllowance;
}else{

startIndex = strUrlW4.lastIndexOf('T4=');
if (startIndex>0){
var strAllowance = strUrlW4.substr(startIndex+3);
document.W4Form.totalAllowances.value = strAllowance;
}
//do nothing
}

//if (document.W4Form.fMarriedFileSingle.checked ==true) document.W4Form.MarriedFileSingle.value = "Y";
//else document.W4Form.MarriedFileSingle.value = "N";

function marriedSingle() {
// set the hidden field for the MarriedFileSingle with Y/N for checked/unchecked event of the check box
if (document.W4Form.fMarriedFileSingle.checked ==true) document.W4Form.MarriedFileSingle.value = "Y";
else document.W4Form.MarriedFileSingle.value = "N";

}


// ARW 3/28/05 SR 1-6103943 Added MarriedFileSingle to function UpdateW4()
function UpdateW4(){

document.updateW4Form.FilingStatus.value = filingStatus;
document.updateW4Form.MarriedFileSingle.value = document.W4Form.marriedSingle.value;
document.updateW4Form.TotalAllowances.value = document.W4Form.TotalAllowances.value;
document.updateW4Form.WithholdingType.value = document.W4Form.WithholdingType.value;
document.updateW4Form.WithholdingAmount.value = document.W4Form.WithholdingAmount.value;

document.updateW4Form.submit();
}


</script>



<!-- end main row -->
<!-- end main table -->
</xsl:template>
 

Your form has no element named "MarriedFileSingle".

Dan


[tt]D'ya think I got where I am today because I dress like Peter Pan here?[/tt]
[banghead]

 

Or... the code cut off mid-post....

Could you post a URL instead?

Dan


[tt]D'ya think I got where I am today because I dress like Peter Pan here?[/tt]
[banghead]

 
cheesus crust - was your other thread with the same title not enough help?

"is null or not an object" means exactly that: what you're referencing is null or not an object.

learn to debug your scripts. start at the root of the offending object/property reference chain, and see where it breaks down.

e.g. if your error is

"document.foo.bar.foobar is null or not an object"

then start by going
alert(document)
alert(document.foo)
alert(document.foo.bar)
alert(document.foo.bar.foobar)

and see when you get "undefined" or "null"

-jeff
try { succeed(); } catch(E) { tryAgain(); } finally { rtfm(); }
i like your sleeves...they're real big
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top