Object error

K

kshah11374

the line
document.getElementByid("sku1").innerHTML = QueryString.values[3];
in the code below gives an error message. What could be the possible
cause?

KS
----------------------------------------------------------------------------------------------------------

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.com/xhtml1/tr/xhtml1-transitional.dtd">
<html>
<head>
<script type="text/javascript">
function QueryString(key)
{
var value = null;
for (var i=0;i<QueryString.keys.length;i++)
{
if (QueryString.keys==key)
{
value = QueryString.values;
break;
}
}
return value;
}

QueryString.keys = new Array();
QueryString.values = new Array();

function QueryString_Parse()
{
var query = location.search.substring(1)
var pairs = query.split("&");

for (var i=0;i<pairs.length;i++)
{
var pos = pairs.indexOf('=');
if (pos >= 0)
{
var argname = pairs.substring(0,pos);
var value = pairs.substring(pos+1);
QueryString.keys = argname;
QueryString.values = value;
}
}
}

QueryString_Parse();

</script>

<title>Dispatching Products</title>
</head>
<body>
<h3>Dispatch Order</h3>
<form action="index.php" method="post">
<table border='1'>
<tr><td><div id='sku1'></div></td><td><div id='desc'></div></
td><td><input type="text" id='quan' size="3" maxlength="3" /></td></
tr>
</table>
<input type="submit" value="Dispatch Order" />
<input type="hidden" name="productid" id="productid" />
</form>

</body>
<script type="text/javascript">
document.getElementById("quan").value = QueryString.values[1];
document.getElementById("desc").innerHTML = QueryString.values[2];
document.getElementByid("sku1").innerHTML = QueryString.values[3];
document.getElementByid("productid").value = QueryString.values[0];
</script>
</html>
 
T

Thomas 'PointedEars' Lahn

the line
document.getElementByid("sku1").innerHTML = QueryString.values[3];
in the code below gives an error message.
http://www.jibbering.com/faq/faq_notes/clj_posts.html#ps1DontWork

What could be the possible cause?

The method name is `getElementById', maybe the assigned value is not HTML,
your markup is not Valid, and it is XHTML, not HTML, which does not make
sense here.

http://validator.w3.org/
http://diveintomark.org/archives/2003/05/05/why_we_wont_help_you
http://hsivonen.iki.fi/xhtml-the-point/


PointedEars
 
S

SAM

(e-mail address removed) a écrit :
the line
document.getElementByid("sku1").innerHTML = QueryString.values[3];
in the code below gives an error message. What could be the possible
cause?

perhaps there is no value ?

var v = QueryString.values[3];
if(typeof v != 'undefined')
document.getElementByid("sku1").innerHTML = v;


--------------------------------

<script type="text/javascript">

var idx = 1;
var pairs = [];
var query = self.location.search.substring(1);
if (query.length>0) {
if(query.indexOf('&')>0) {
pairs = query.split('&');
if(pairs.length>0) {
for(var i=0; i<pairs.length; i++) {
pairs = pairs.split('=');
idx++;
}
}
}
else {
pairs[0] = query.split('=');
}
}
function completText(id, n) {
if(n<idx)
document.getElementById(id).innerHTML = pairs[n][1];
}
function completVal(id, n) {
if(n<idx)
document.getElementById(id).value = pairs[n][1];
}
alert(idx+'\n'+pairs);
</script>

</head>
<body>

<p><span id="un"></span><input id="trois" /></p>
<p><span id="deux"></span><input id="katr" /></p>

<script type="text/javascript">
completText('un', 0);
completVal('trois', 1);
completText('deux', 2);
completVal('katr', 3);
</script>
 
T

T. Rex

the line
document.getElementByid("sku1").innerHTML = QueryString.values[3];
in the code below gives an error message. What could be the possible
cause?

You have an error, obviously.

If you want a more specific answer, you need to give more specific
information, like what the error message says.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top