PDA

View Full Version : sending data without clicking on submit


darp
09-21-2002, 10:05 AM
i want to send some information to a remote website by using a form.

but the thing is i want to put this form in a loop. so i will not need to click on "submit" everytime. it will send the data automatically.

but of course it does not send the information without clicking on "submit". how can i do that? how can i send infofmation without hiting on submit?

thanks..

piglet
09-21-2002, 11:18 AM
Hi darp,

The normal way to send data back to a server from Javascript without submitting a form is to pass the information back to a server-side script using an Image request.

More information is on this link (http://www.webxpertz.net/forums/showthread.php3?s=&threadid=19205)

darp
09-21-2002, 12:56 PM
yep this looks like the thing i am looking for. but i am not good with asp and javascript. so how am i gona convert it to the way i need?

this is the original form:

<form action=http://www.blabla.com/blabla.dll method=post>
<input type=text name=subject value="this is the subjext">
<input type=text name=body value="this is the body">
<input type=submit value=submit></form>

should the function be like this?

<%
function senddata(variablename){
var x = new Image();
var y = new Image();
x.src="http://www.blabla.com/blabla.dll?var="+variablename;
y.src="http://www.blabla.com/blabla.dll?var="+variablename;
}
%>

and how i am gona call the function?

piglet
09-23-2002, 08:34 AM
Hi darp,


<form name="foo">
<input type=text name=subject value="this is the subjext">
<input type=text name=body value="this is the body">
<input type="button" value="submit" onclick="senddata(this.form)"></form>

<script>
function senddata(f){
var x = new Image();
x.src="http://www.blabla.com/blabla.dll?subject ="+f.subject.value+"&amp;body="+f.body.value;
}

//you can also submit the data:

senddata(document.forms["foo"]);

</script>


I'm not quite awake yet this morning - you may need to escape the variables before sending them:

escape(f.subject.value) etc

darp
09-23-2002, 01:39 PM
this is great.
thanks.