Dynamically alter input element javascript on submit form
<p>I am trying to create a submit form whereby i alter one of the input elements to add the contents of a cookie and whereby this content is emailed along with the other input elements. I have tried various methods including accessing the value attribute and appending a child element but to no avail, using firefox.</p>

<p><strong>HTML</strong></p>

<pre><code>&lt;form method="GET" action="mailto:davidflynn12@hotmail.com"&gt;
    &lt;input type="hidden" name="subject" value="javascript:GetTotal()"&gt;
    &lt;input type="hidden" name="body" value="test"&gt;
    &lt;input type="submit" value="Send Email"&gt;
&lt;/form&gt;
&lt;form id="form1" action="mailto:admin@example.com" enctype="text/plain"
method="post"&gt;
    &lt;a href="javascript:addOption()"&gt;Add Details &lt;/a&gt;
    &lt;p&gt;Name:
        &lt;input name="Name" type="text" id="Name" size="40" value=javascript:GetTotal()&gt;
    &lt;/p&gt;
    &lt;p&gt;E-mail address:
        &lt;input name="E-mail" type="text" id="E-mail" size="40"&gt;
    &lt;/p&gt;
    &lt;p&gt;Comment:&lt;/p&gt;
    &lt;p&gt;
        &lt;textarea name="Comment" cols="55" rows="5" id="Comment"&gt;&lt;/textarea&gt;
    &lt;/p&gt;
    &lt;p&gt;
        &lt;input type="submit" name="Submit" value="Submit"&gt;
    &lt;/p&gt;
&lt;/form&gt;
</code></pre>

<p><strong>JS</strong></p>

<pre><code>function GetTotal() {
    // Get the individual cookies, by splitting the cookie string
    // Individual cookies is now an array of all the name=value pairs
    var individualCookies = document.cookie.split(';');
    var temp3 = 0;
    //document.write("&lt;p class = 'special_p'&gt;");
    for (var i = 0; i &lt; individualCookies.length; i++) {
        // Loop through each of the cookies, and split them into
        // their name and value, as separate elements in the array
        var oneCookie = individualCookies[i].split("=");
        var name = oneCookie[0];
        var value = oneCookie[1];


        // This is standard code for removing excess white space
        name = name.replace(/^\s+|\s+$/g, '');
        //document.write("&lt;ul&gt;");
        document.write("&lt;ul&gt;");
        if (name == 'History of Boxing') {
            var temp = 7;
            var temp2 = temp * value;
            document.write("&lt;li class = 'special_p'&gt;" + name + " By David
                                Flynn. No. of Copies: " + value + ".Total cost
                                =" + temp2 + "Euros&lt;/li&gt;");
        } else if (name == 'Future of Boxing') {
            var temp = 8;
            var temp2 = temp * value;
            document.write("&lt;li class = 'special_p'&gt;" + name + " By
                                    David Flynn. No. of Copies: " + value + ".Total cost =
                                    " + temp2 + "Euros&lt;/li&gt;");
        } else if (name == 'History of TaeKwondo') {
            var temp = 9;
            var temp2 = temp * value;
            document.write("&lt;li class =
                                                'special_p'&gt;" + name + " By David Flynn. No.
                                                of Copies: " + value + ".Total cost =
                                                " + temp2 + "Euros&lt;/li&gt;");

        } else if (name == 'Future of TaeKwondo') {
            var temp = 10;
            var temp2 = temp * value;
            document.write("&lt;li class =
                                                'special_p'&gt;" + name + " By David Flynn. No.
                                                of Copies: " + value + ".Total cost =
                                                " + temp2 + "Euros&lt;/li&gt;");

        }
        document.write("&lt;/ul&gt;");
        temp3 += temp2;
        //document.write("Grand total = "+temp3"):
    }
    document.write("&lt;p class = 'special_p'&gt;Total bill is
                                " + temp3 + " Euros&lt;/p&gt;");
    //document.write("&lt;/p&gt;");
}
</code></pre>
