wizmay
05-26-2006, 03:57 AM
I'm quite new at JavaScript, anyway I'm trying to use it to write code to auto click the submit button in a web page. Here's my code:
<html>
<head>
<script LANGUAGE="JavaScript">
var m_alert = "2";
var m_type = "top";
var m_mode = "normal";
var m_xmlpage = "http://192.168.1.10/topline.xml";
var m_method = "get";
var m_ap = "";
setTimeout("document.xmlform.submit()",2000); //After loading the page, wait 2 secs then submit form
function PushMsg() {
xmlform.action = "http://192.168.1.11"; //After hitting submit button, it will go to this url...
m_ap = '<\?xml version="1.0"?>\n'+
'<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.3//EN"\n'+
'"http://www.wapforum.org/DTD/wml13.dtd">\n'+
'<Push alert= "'+m_alert+'" type="'+m_type+'" mode="'+m_mode+'">\n'+
'<go href= "'+m_xmlpage+'" method = "'+m_method+'">\n'+
'</go>\n'+
'</Push>\n\r';
document.forms[0].XMLData.value = m_ap; //...and also send these data to the target url
}
</script>
</head>
<body>
<form name="xmlform" method="POST" onSubmit="return PushMsg()">
<input type="hidden" name="XMLData">
<input type="submit" value="Submit" name="B1">
</form>
</body>
</html>
Well, I use this page to work with some other pages. This page will be called at the specific time, for example at 9am, 12pm and 5pm the other php page will automatically call this page, then hit submit button in order to send the hidden data in a form tag (<input type="hidden" name="XMLData">) to the target url.
The problem is, currently it can automatically submit the form, but it doesn't do the onSubmit="return PushMsg()" part, so the PushMsg() is not called to work. Now, instead of going to the target url (http://192.168.1.11) after submitting the form, it just refreshes the same page every 2 secs. However, the code works if I click the submit button myself.
Is there any way to correct the problem? :confused:
<html>
<head>
<script LANGUAGE="JavaScript">
var m_alert = "2";
var m_type = "top";
var m_mode = "normal";
var m_xmlpage = "http://192.168.1.10/topline.xml";
var m_method = "get";
var m_ap = "";
setTimeout("document.xmlform.submit()",2000); //After loading the page, wait 2 secs then submit form
function PushMsg() {
xmlform.action = "http://192.168.1.11"; //After hitting submit button, it will go to this url...
m_ap = '<\?xml version="1.0"?>\n'+
'<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.3//EN"\n'+
'"http://www.wapforum.org/DTD/wml13.dtd">\n'+
'<Push alert= "'+m_alert+'" type="'+m_type+'" mode="'+m_mode+'">\n'+
'<go href= "'+m_xmlpage+'" method = "'+m_method+'">\n'+
'</go>\n'+
'</Push>\n\r';
document.forms[0].XMLData.value = m_ap; //...and also send these data to the target url
}
</script>
</head>
<body>
<form name="xmlform" method="POST" onSubmit="return PushMsg()">
<input type="hidden" name="XMLData">
<input type="submit" value="Submit" name="B1">
</form>
</body>
</html>
Well, I use this page to work with some other pages. This page will be called at the specific time, for example at 9am, 12pm and 5pm the other php page will automatically call this page, then hit submit button in order to send the hidden data in a form tag (<input type="hidden" name="XMLData">) to the target url.
The problem is, currently it can automatically submit the form, but it doesn't do the onSubmit="return PushMsg()" part, so the PushMsg() is not called to work. Now, instead of going to the target url (http://192.168.1.11) after submitting the form, it just refreshes the same page every 2 secs. However, the code works if I click the submit button myself.
Is there any way to correct the problem? :confused: