PDA

View Full Version : trouble printing ampersand in subjectline.


jefgees
02-19-2003, 11:31 AM
thanks to head8k I 've got a nice script offering me an e-mail with a predifined subject. But i still got trouble for getting the ampersand. It shows correct in the browser, but when it comes to printing it into an email everything that starts from the ampersand disappears.
Can someone please help me and tell me what I'm doing wrong??
Thanks.
Hereby the code :

<html>
<head>
<title>predefined subject</title>
<script>
<!--
function changeMailto(i){
mailtoString = "<a href=\"mailto:?subject="+i+" - text ( )\">IMAGE</a>";
document.getElementById('test').innerHTML = mailtoString;
}
-->
</script>
</head>
<body>

<form>
<select onchange="changeMailto(this.options[this.selectedIndex].value)">
<option value="apples &amp; oranges">apples &amp; oranges</option>
<option value="bananas &amp; peaches">bananas &amp; peaches</option>
<option value="stones &amp; rain">stones &amp; rain</option>
</select>
</form>

<br />

<div name="test" id="test"></div>

</body>
</html>

MrDoubtFire
02-19-2003, 01:33 PM
Have you tried using the literal code for & ? (the amp; with the & before it)

MrDF

arnyinc
02-19-2003, 01:43 PM
This works for me, but it worries me that the link looks the exact same when you mouseover the link.

<script>
<!--
function changeMailto(i){
i = escape(i);
mailtoString = "<a href=\"mailto:?subject="+i+" - text ( )\">IMAGE</a>";
document.getElementById('test').innerHTML = mailtoString;
}
-->
</script>

jefgees
02-19-2003, 02:46 PM
I already tried your suggestion but it does not work. Hereby the code as I try to use it:

<html>
<head>
<title>predefined subject</title>
<script>
<!--
function changeMailto(i){
mailtoString = "<a href=\"mailto:?subject="+i+" - text ( )\">IMAGE</a>";
document.getElementById('test').innerHTML = mailtoString;
}
-->
</script>
</head>
<body>

<form>
<select onchange="changeMailto(this.options[this.selectedIndex].value)">
<option value="apples &amp; oranges">apples &amp; oranges</option>
<option value="bananas &amp; peaches">bananas &amp; peaches</option>
<option value="stones &amp; rain">stones &amp; rain</option>
</select>
</form>

<br />

<div name="test" id="test"></div>

</body>
</html>

jefgees
02-19-2003, 02:50 PM
I noticed that when I paste the code the code "amp;" with "&" before it disapperas in the window on this code forum.. But you can be sure I use this syntax in my page layout and still it does not work..

Anyone who knows wat is going wrong here???

arnyinc
02-19-2003, 05:07 PM
Did you try adding this line into your javascript?

i = escape(i);

Like I said, this fixes the problem for me (in IE and Mozilla).

jefgees
02-20-2003, 07:12 AM
Arnyinc,
thanks a lot. It works perfect!!!
Muchas graçias(

JG