I have made a Formula with on onchange="this.form.submit()"
and a automatic page refresh function with window.location.replace();
. My Problem is, that i need to know where the user clicked in the last time. My Solution was a second onclick="" event to get the id of the selected field. This works fine if i make no changes in the form. When i change some values and go to a other field, the onclick function didn't work.
How can i solve this problem? And by the way, sorry for my bad english.
<input name="'.$idname.'" value="'.$cont_field.'" type="text" class="loginField" size="'.$breite.'" style="width:98%;" id="'.$idname.'" onchange="this.form.submit()" onclick="focusCookie(event)">
<script type="text/javascript">
function focusCookie (event) {
event = event || window.event;
var target = event.target || event.srcElement;
var anch = target.id;
createCookie("anchor", anch, new Date(new Date().getTime() + 10000));
}
function createCookie(name, value, expires, path, domain) {
var cookie = name + "=" + escape(value) + ";";
if (expires) {
if(expires instanceof Date) {
if (isNaN(expires.getTime()))
expires = new Date();
}
else
expires = new Date(new Date().getTime() + parseInt(expires) * 1000 * 60 * 60 * 24);
cookie += "expires=" + expires.toGMTString() + ";";
}
if (path)
cookie += "path=" + path + ";";
if (domain)
cookie += "domain=" + domain + ";";
document.cookie = cookie;
}
</script>
And this ist the loadingfunction
//--> Loaders
function Loader($https_url,$seite,$loader_id){
$loaderurl = '<script type="text/javascript">window.location.replace("'.$https_url.'/index.php?inhalt=extranet&extra=formular&seite='.$seite.'#'.$loader_id).'");</script>';
return $loaderurl;
}
Ok 2 Problems solved and 1 still pending. I can send the form and catch the anchor tag befor. But after the Siteload the focus(); is lost...
Here my Code:
<script type="text/javascript">
function submitform (event) {
event = event || window.event;
var target = event.target || event.srcElement;
var anch = target.id;
createCookie("anchor", anch, new Date(new Date().getTime() + 10000));
sendeForm();
document.getElementById(anch).reload();
}
function createCookie(name, value, expires, path, domain) {
var cookie = name + "=" + escape(value) + ";";
if (expires) {
if(expires instanceof Date) {
if (isNaN(expires.getTime()))
expires = new Date();
}
else
expires = new Date(new Date().getTime() + parseInt(expires) * 1000 * 60 * 60 * 24);
cookie += "expires=" + expires.toGMTString() + ";";
}
if (path)
cookie += "path=" + path + ";";
if (domain)
cookie += "domain=" + domain + ";";
document.cookie = cookie;
}
function sendeForm(){
document.getElementById("ID").submit();
}
</script>