I have a form that has specific field layouts that does not use <p <a formats so i need a javascrip function. the href work just great it pops up a client side email form and prefills the "to" and "subject". this is a scheduling form and the user may want to contact the supplier with a email so there are two email fields setup on the form. i tried a button, radio button and used the onsubmit and onradiochanged both give errors function not part of form then I used textbox onchange. that calls the function smail()
i've tried several ways. last one is here. but it come up with two messages first is a form is being submited to email, second is an application is try to send a email. i answer ok to first and yes to second. but system does nothing. I just want it to pop up a new email message window and prefill To: and subject field from e1 or e2 or e1 & e2 textboxes.
here is function sofar.

function smail() {
alert ("mailto:" + document.forms[0].EmailTextbox.value +"?subject=Hi");
var eminfo = "mailto:" + document.forms[0].EmailTextbox.value +"?subject=Hi" ;
document.forms[0].action = eminfo;
document.forms[0].submit();
return ;
}
function smaila() {
alert ("mailto:" + document.forms[0].AltEmailTextbox.value +"?subject=Hi");
var eminfo1 = "mailto:" + document.forms[0].AltEmailTextbox.value +"?subject=Hi" ;
document.forms[0].action = eminfo1;
//document.forms[0].submit();
return false;
}
function smailb() {
alert ("mailto:" + document.forms[0].EmailTextbox.value + "; " + document.forms[0].AltEmailTextbox.value  +";?subject=Hi");
var eminfoall = "mailto:" + document.forms[0].EmailTextbox.value + "; " + document.forms[0].AltEmailTextbox.value  +";?subject=Hi" ;
document.forms[0].action = eminfoall;
//document.forms[0].submit();
return false;
}

TIA sqlchopper as you may see this is my second script I've tried to write.

Please use code tags. Please use English, including proper punctuation, spelling, and grammer, as far as possible.

I personally found your message incomprehensible... what does "used the onsubmit and onradiochanged both give errors function not part of form" mean??

Please use code tags. Please use English, including proper punctuation, spelling, and grammer, as far as possible.

I personally found your message incomprehensible... what does "used the onsubmit and onradiochanged both give errors function not part of form" mean??

I tried using a "button" and then tried a "radiobutton". sorry, i tend to get wordy and try to keep messages short.

But, what is your actual question? It's lost in run-on sentences and code postings.

Going just from your thread title: you can set the action tag of a form by retrieving the form (the method depends of course on your DOCTYPE), and setting the "action" attribute to a string.

Sorry, this is wordy.
Let me back up. I have developed a Intra company vendor scheduling web system using ms vb.net. On the scheduling form everything uses absolute positioning.
I've just added two texbox for user to record email addresses. Users want to be able to click on something and have the system pop up a email and prefill it with the email infomation in the textbox. They want three options; Send email using addresses from textbox 1, or from textbox 2, or from both textbox 1 and 2.
PROBLEM 1: I need to anchor the 3 new href links in a absolute position on the screen and develope a function to replace the send to info in the href on the fly based on info in textbox.
I first put a button on the form and used the "onClick" to call the function. That try gave me the error "error smail function not part of web page"
I then tried using a radiobutton and used the "onradiochanged" but got the same error.
So I created a small textbox and use the "onblur" event to kick off the function I posted.
Problem 2: How do I modify the 3 new existing href links with the info from the email textbox areas. It seams after reading tons of stuff on the web that I can not use a javascript function to kick off a email. The function with the "action =" and "submit" works but no email come up and whatever was created goes to nevernever land. I thought of using the Form "onload" event to call the function and I would also have to update the links if info is changed.

resolved. here is code.

// this is javascript source.
datareview.js
        function smail() {
            smaila();
            smailb();
            smailc();
            return;
            }
        function smaila() {
            var x = document.getElementById('table2').rows[0].cells;
            x[0].innerHTML = "<a href=mailto:" + document.forms[0].EmailTextbox.value + "?subject=Hi" + ">Email</a>";
            //alert (x[0].innerHTML);
            return ;            
            }
    function smailb() {
            var x = document.getElementById('table3').rows[0].cells;
            x[0].innerHTML = "<a href=mailto:" + document.forms[0].AltEmailTextbox.value +"?subject=Hi" + ">Email</a>";
            //alert (x[0].innerHTML);
            return ;            
            }
    function smailc() {
            var x = document.getElementById('table4').rows[0].cells;
                    x[0].innerHTML = "<a href=mailto:" + document.forms[0].EmailTextbox.value + "; " + document.forms[0].AltEmailTextbox.value  +"?subject=Hi" + ">Email</a>";
            //alert (x[0].innerHTML);
            return ;            
            }
        function kH(e) {
            var pK = e ? e.which : window.event.keyCode;
            return pK != 13;
            }
// end of datareview.js
<HTML>
    <HEAD>
        <title>PARSDataReview</title>
        <meta content="False" name="vs_snapToGrid">
        <meta content="Microsoft Visual Studio.NET 7.0" name="GENERATOR">
        <meta content="Visual Basic 7.0" name="CODE_LANGUAGE">
        <meta content="JavaScript" name="vs_defaultClientScript">
        <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
        <script src="datareview.js" type="text/javascript"></script>
        <script type="text/javascript"><!-- 
        <!-- used to disable the enter key press
        document.onkeypress = kH;
        if (document.layers) document.captureEvents(Event.KEYPRESS);
        file://-->
        </script>
    </HEAD>
    <body onload="smail()" bgColor="#fff8bb" XMLNS:igtbl="http://schemas.infragistics.com/ASPNET/WebControls/UltraWebGrid"
        MS_POSITIONING="GridLayout">
        <form id="Form1" method="post" runat="server">
    
    <form>
        <TABLE id="Table2" style="Z-INDEX: 402; LEFT: 898px; WIDTH: 36px; POSITION: absolute; TOP: 134px; HEIGHT: 27px"
            cellSpacing="1" cellPadding="1" width="36" border=0>
            <TR>
            <TD><a href="mailto:?subject=Hi">Email</a></TD>
            </TR>
        </TABLE>
        <TABLE id=Table3 style="Z-INDEX: 403; LEFT: 899px; WIDTH: 76px; POSITION: absolute; TOP: 181px; HEIGHT: 9px" 
            cellSpacing=1 cellPadding=1 width=76 border=0>
            <TR>
            <TD><A href="mailto:?subject=Hi">Email Alt</A></TD>
            </TR>
        </TABLE>
        <TABLE id=Table4 style="Z-INDEX: 406; LEFT: 900px; WIDTH: 76px; POSITION: absolute; TOP: 206px; HEIGHT: 9px" 
            cellSpacing=1 cellPadding=1 width=76 border=0>
             <TR>
            <TD><A href="mailto:?subject=Hi">Email Both</A></TD>
            </TR>
        </TABLE>
    </form>
 </Body>
</HTML>

This is pretty straight forward and requires just the following javascript code:

window.location = "mailto:email@webaddress.com?subject=email subject&body=Email paragraph text"

hope this helps someone

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.