javascript - getElementById not returning proper value (maybe syntax issue?) -
i using xsl write page, , when hit checkbox sends information javascript function. works in ie, chrome not. problem is, after hit checkbox, field comes "undefined"
<div id="part1" value="0-ser-mn">undefined</div>
where
<div id="part1" value="0-ser-mn">0-ser-mn</div>
my guess value being returned "null" don't know why? can help? thanks.
<td colspan="2"> <div> <xsl:attribute name="id">part<xsl:value-of select="position()"/></xsl:attribute> <xsl:attribute name="value"><xsl:value-of select="part"/></xsl:attribute> <xsl:if test="errormessage"> <input type="hidden" name="partnumber"> <xsl:attribute name="value"><xsl:value-of select="part"/></xsl:attribute> </input> <input type="hidden" name="tempkey"> <xsl:attribute name="value"><xsl:value-of select="tempkey"/></xsl:attribute> </input> </xsl:if> <xsl:value-of select="./part"></xsl:value-of> </div> </td>
so here javascript selected checkbox
function turnonorder(index, tempkey) { document.getelementbyid('part' + index).innerhtml = '<input type="hidden" name="partnumber" value="' + document.getelementbyid('part' + index).value + '"></input> <input type="hidden" name="tempkey" value="' + tempkey + '"/>' + document.getelementbyid('part' + index).value; document.getelementbyid('location' + index).innerhtml = '<input type="hidden" name="location" value="' + document.getelementbyid('location' + index).value + '"></input> ' + document.getelementbyid('location' + index).value; document.getelementbyid('site' + index).innerhtml = '<input type="hidden" name="sitecode" value="' + document.getelementbyid('site' + index).value + '"></input> ' + document.getelementbyid('site' + index).value; document.getelementbyid('ponumber' + index).innerhtml = '<input type="hidden" name="origpo" value="' + document.getelementbyid('ponumber' + index).value + '"></input><input size="20" maxlength="20" type="text" name="ponumber" value="' + document.getelementbyid('ponumber' + index).value + '"></input>'; document.getelementbyid('quantity' + index).innerhtml = '<input type="hidden" name="orderqty" value="' + document.getelementbyid('quantity' + index).value + '"></input> ' + document.getelementbyid('quantity' + index).value; if(document.getelementbyid('viewprice') == null) document.getelementbyid('price' + index).innerhtml = '<input type="hidden" name="price" value="' + document.getelementbyid('price' + index).value + '"></input> '; else document.getelementbyid('price' + index).innerhtml = '<input type="hidden" name="price" value="' + document.getelementbyid('price' + index).value + '"></input> ' + document.getelementbyid('price' + index).value; document.getelementbyid('userid' + index).innerhtml = '<input type="hidden" name="userid" value="' + document.getelementbyid('userid' + index).value + '"></input> '; //document.getelementbyid('inactiveoverride' + index).innerhtml = '<input type="hidden" name="inactiveoverride" value="' + document.getelementbyid('inactiveoverride' + index).value + '"/>'; //document.getelementbyid('mpqmoqoverride' + index).innerhtml = '<input type="hidden" name="mpqmoqoverride" value="' + document.getelementbyid('mpqmoqoverride' + index).value + '"/>'; document.getelementbyid('other' + index).innerhtml = '<input type="hidden" name="supplier" value="' + document.getelementbyid('supplier' + index).value + '"></input><input type="hidden" name="icst" value="' + document.getelementbyid('icst' + index).value + '"></input><input type="hidden" name="backflush" value="' + document.getelementbyid('backflush' + index).value + '"></input><input type="hidden" name="billing" value="' + document.getelementbyid('billing' + index).value + '"></input><input type="hidden" name="inactiveoverride" value="' + document.getelementbyid('inactiveoverride' + index).value + '"/><input type="hidden" name="mpqmoqoverride" value="' + document.getelementbyid('mpqmoqoverride' + index).value + '"/>'; }
this seems javascript dom access issue. , has nothing xslt.
the problem based on difference between dom property , html attributes , different handling in browsers. in cases using dom property (dom-elment.attribute-name) should work. because browser synchronize html attribute dom property. not happen (in chrome etc.) customer attribute (e.g value attribute @ div).
therefore should use
document.getelementbyid('part' + index).getattribute('value')
in replacement document.getelementbyid('part' + index).value
this should work in reasonable modern browsers (e.g ie > 6)
Comments
Post a Comment