PDA

View Full Version : Field duplicate/copy onblur/click etc... other way to do?



noobster
07-10-2007, 02:34 PM
Hi,

what i have:

-->2 forms because i have to (sorry no time to explain)
-->1 form contains a adobe spry suggest menu, suggesting dropdown via DIV, so it's in fact a textarea.
-->I use this :onMouseOver="document.form1.select3.value=this.value;
Here is MouseOver but i tried all other events i think.


What i need:
-->To copy the "fake" dropdown value to another hidden filed in the other form of my page.

What's wrong:
--> when i Type, i works , it auto updates as i type in, but when i click on a dropdown value , it doesn't take my new value, it just reflects the few letters i typed "by hand". Or i have to click in another field, or mouseover the field with my mouse etc..to force update.

I can't rely on that cause a user will always be able to bypass that even if he didn't really wanted to.

Is there another way to autoupdate/copy/duplicate in real time these two fields?

thanks for any help

Trinithis
07-11-2007, 12:42 AM
function refreshFormValue(baseForm, targetForm) {
targetForm.value = baseForm.value;
}

setInterval(
(function() {
return function() {
refreshFormValue(
(function(){return document.getElementById("base")})(),
(function(){return document.getElementById("target")})()
)}
}
)(),
50
);


A working HTML example:


<html>
<head>
<title>Test</title>
</head>
<body>


<textarea id="base"></textarea>
<br />
<textarea id="target"></textarea>


<script type="text/javascript">
function refreshFormValue(baseForm, targetForm) {
targetForm.value = baseForm.value;
}

setInterval(
(function() {
return function() {
refreshFormValue(
(function(){return document.getElementById("base")})(),
(function(){return document.getElementById("target")})()
)}
}
)(),
50
);
</script>

</body>
</html>

noobster
07-11-2007, 09:04 AM
thanks a lot for your clear answer. i'll try that as soon as possible.

Thanks again for your time