471,091 Members | 1,526 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,091 software developers and data experts.

Why doesn't parser like this script?

Hi, I'm using the following script to pass 3 variables to my next
form.

function Anomaly(typeIn,idIn,textIn)
{
var sType = 'type=' typeIn
var sIdNo = '&idNo=' idIn
var sText = '&text=' textIn

newWindow = window.open(('Anomaly.aspx?' + sType + sIdNo + sText),
'Anomaly', 'width=650')
}

My parser (msxml4) "thinks" there is a problem with variables sIdNo
and sText -- the &'s are causing it (expecting a semicolon after
'&idNo='). It functions but I don't want the user to see the browser
error...how else to I pass the multiple parameters?

Any thoughts?

Thanks, Kathy
Jul 20 '05 #1
3 1404
Ka**********@attbi.com (KathyB) writes:
var sType = 'type=' typeIn
Do you mean:
var sType = 'type=' + typeIn

(and I would add a semicolon at the end, even though it isn't necessary).
var sIdNo = '&idNo=' idIn
var sText = '&text=' textIn


Dittos.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2


KathyB wrote:
Hi, I'm using the following script to pass 3 variables to my next
form.

function Anomaly(typeIn,idIn,textIn)
{
var sType = 'type=' typeIn
var sIdNo = '&idNo=' idIn
var sText = '&text=' textIn

newWindow = window.open(('Anomaly.aspx?' + sType + sIdNo + sText),
'Anomaly', 'width=650')
}

My parser (msxml4) "thinks" there is a problem with variables sIdNo
and sText -- the &'s are causing it (expecting a semicolon after
'&idNo='). It functions but I don't want the user to see the browser
error...how else to I pass the multiple parameters?

Any thoughts?


MSXML 4 is an XML parser, if you are using it to parse HTML pages then
forget about that. If you are trying to author XHTML then you need to
follow XML rules where you would need to use
&amp;
to escape an ampersand. However as you are probably trying to send XHTML
as text/html to HTML browsers you need another approach, one way is to
not use inline scripts but only external script files, another way is to use
<script type="text/javascript">
//<![CDATA[
script goes here
//]]>
</script>
that way your page is well-formed XML while being properly handled by
HTML browsers.
I (and others) however strongly suggest to use HTML 4.01 instead of
XHTML 1.0, see for instance
http://www.hixie.ch/advocacy/xhtml

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #3
It _might_ be because you are missing + in your var calls.

var sType = 'type=' + typeIn;
var sIdNo = '&idNo=' + idIn;
var sText = '&text=' + textIn;

Best way to test is try:-

function Anomaly(typeIn,idIn,textIn)
{
var sType = 'type=' + typeIn;
var sIdNo = '&idNo=' + idIn;
var sText = '&text=' + textIn;
alert('Anomaly.aspx?' + sType + sIdNo + sText);
}

This will alert the total url line that is openeing in your popup window.

Stu

"KathyB" <Ka**********@attbi.com> wrote in message
news:75**************************@posting.google.c om...
Hi, I'm using the following script to pass 3 variables to my next
form.

function Anomaly(typeIn,idIn,textIn)
{
var sType = 'type=' typeIn
var sIdNo = '&idNo=' idIn
var sText = '&text=' textIn

newWindow = window.open(('Anomaly.aspx?' + sType + sIdNo + sText),
'Anomaly', 'width=650')
}

My parser (msxml4) "thinks" there is a problem with variables sIdNo
and sText -- the &'s are causing it (expecting a semicolon after
'&idNo='). It functions but I don't want the user to see the browser
error...how else to I pass the multiple parameters?

Any thoughts?

Thanks, Kathy

Jul 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by none | last post: by
7 posts views Thread by jagsmiles | last post: by
reply views Thread by Bob Bedford | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.