Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fill another field, Javascript



Robert:

<input name="print_name" id="print_name" type="text" style="height:25px; width: 400px;" value="print_name" size="8" maxlength="32" class="Ih2E3d">_name').value = this.value" />

You can do it with functions if you want to be more flexible. Something like:

<head>

<script language="_javascript_">

function replaceValue(whatid,withvalue)
{
    document.getElementById("whatid").value = withvalue;
    return true;
}

</script>
</head>

<body>

Input 1:
<input type="text" id="textOne" name="textOne" />
<br />
<br />
Carbon Copy:
<input type="text" id="carbonText" name="carbonText">

</body>



Okay, I think that will work. I didn't test it, just typed it in gmail. Good luck.

- paul
On Thu, Apr 3, 2008 at 5:43 PM, Walter Lee Davis <email@hidden> wrote:
There's as many ways to do this as there are developers. The answer in this case is yes, and...

You could also do this unobtrusively, with no need to mark anything up in the view.

//in the head
<script src="" type="text/_javascript_"></script>
<script type="text/_javascript_">
Event.observe(window,'load', function(){
       new Form.Element.Observer('print_name',
               0.3,
               function(elm,value){
                       $('i_name').value = value;
               }
       );
});
</script>

//in the body

<input id="print_name" name="print_name" type="text" />
<input id="i_name" name="i_name" type="text" />

This sets up an observer that watches the first element for any changes, and every 300 milliseconds updates the second element with the current value of the first.

You can learn more about Prototype here: http://prototypejs.org

Walter


On Apr 3, 2008, at 7:37 PM, Robert Poland wrote:
Hi,

Maybe I'm misunderstanding all the kind help here.

Should a line like this work or do I need to call a function?

<input name="print_name" id="print_name" type="text" style="height:25px; width: 400px;" value="print_name" size="8" maxlength="32" = print_name.value" />


On Apr 3, 2008, at 3:21 PM, John Jarrard wrote:

Hi Bob,
       Use an onkeyup or onblur event...

JJ


On Apr 3, 2008, at 3:20 PM, Robert Poland wrote:

Hi,

On a form I wish to fill field2 with a value I am typing into field1.

I realize I can do this with an onclick but isn't there a way to , for instance do it with onreturn?


Bob Poland - Fort Collins, CO



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Web-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/web-dev/email@hidden

This email sent to email@hidden



Bob Poland - Fort Collins, CO



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Web-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/web-dev/email@hidden

This email sent to email@hidden

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Web-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/web-dev/email@hidden

This email sent to email@hidden



--
map in style...... www.googmappin.com
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Web-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/web-dev/email@hidden

This email sent to email@hidden

References: 
 >Fill another field, Javascript (From: Robert Poland <email@hidden>)
 >Re: Fill another field, Javascript (From: Robert Poland <email@hidden>)
 >Re: Fill another field, Javascript (From: Walter Lee Davis <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.