Results 1 to 3 of 3

Thread: Field duplicate/copy onblur/click etc... other way to do?

  1. #1
    Join Date
    Jun 2006
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Field duplicate/copy onblur/click etc... other way to do?

    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

  2. #2
    Join Date
    May 2007
    Location
    USA
    Posts
    373
    Thanks
    2
    Thanked 4 Times in 4 Posts

    Default

    Code:
    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:
    Code:
    <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>
    Last edited by Trinithis; 07-11-2007 at 04:47 AM. Reason: *did not edit*

  3. #3
    Join Date
    Jun 2006
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    thanks a lot for your clear answer. i'll try that as soon as possible.

    Thanks again for your time

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •