Click to See Complete Forum and Search --> : What is wrong with this code??


shanuragu
10-16-2003, 02:28 AM
Hi

I am planning to implement the following functionality in my web site.

<html>
<head>
<script language="javascript">
function mailThisUrl()
{
mail = "mailto:" + "document.address.value?subject=This page might interest you";
mail += "&body=" + "http://www.bhagavadgita.com";
location.href = mail;
}
</script>
</head>
<body>
Recommend my page to a friend!
<br />
Recipient's e-mail address
<br />
<input type="text" name="address" value="" size="25">
<input type="button" value="Send" onClick="mailThisUrl();">
</body>
</html>

I am unable to display Address in the email box To: field

How can I fetch the text value without using asp???

shara

Gollum
10-16-2003, 02:54 AM
I'd suggest using id instead of name since you're not using forms in your example...


function mailThisUrl()
{
mail = 'mailto: + document.getElementById('address') + '?subject=This page might interest you';
mail += '&body=http://www.bhagavadgita.com';
location.href = mail
}

then...

<input type="text" id="address" value="" size="25">

shanuragu
10-16-2003, 03:06 AM
No change
With the previous code itself I am able to display subject, body And the title except the To field value, which is replaced by document.address.value itself in the email.

Some silly mistake I have made - unable to trace it

please help

shara

shanuragu
10-16-2003, 03:14 AM
Hi

I am through
I just made a small change in my previous code ie,

mail = "mailto:" + document.form.address.value + '?subject=This page might interest you';

it is working fine now.

thanks for ur help

shara:D

lillu
10-16-2003, 03:34 AM
Oh, you solved it anyway...

Just wanted to say that include input tags within a form and everything will be fine.

<html>
<head>
<script language="javascript">
function mailpage()
{
mail_str = "mailto:" + document.form1.address.value;
mail_str += "?subject=I recommend this link";
// put more details eg. body here
location.href = mail_str;
}
</script>
</head>
<body>
<form name="form1">
<input type="text" value="" name="address" />
<input type="submit" onclick="mailpage()" value="Send" />
</form>