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: Using javascript inside a WOPopup



Denis, I recommend using Mozilla/Firefox for all javascript development, because the javascript debuggers are invaluable. Type
javascript:
in the URL, and it will open a javascript log. If you're feeling ambitious, you can open the Javascript Debugger, which allows you to step through your scripts just like the XCode debugger.


For your specific setup, I'd recommend something like this (very rough untested code)

<select onchange="didChooseCurrency(this);"><option>...</option></select>
<input name="exchangeRate" />


<script>
function didChooseCurrency(sender) {
	var newExchangeRate = sender.options[sender.selectedIndex - 1].value;
	sender.form.exchangeRate.value = newExchangeRate;
}
</script>



On May 29, 2004, at 9:26 PM, Denis Stanton wrote:

Can any one help me with a line of javascript to be executed when a WO
PopUpButton is changed?

I am familiar with adding an extra binding to a popUpButton of the form:
onChange = "form.submit();"


In this case I want to do something different.  My application is
recording payments on several currencies. I have a popUpButton to
select a currency from a small array.  The next TextField displays the
exchange rate.  Selecting a currency *copies* an exchange rate from the
currency table into the payment's exchange rate field.  The individual
payment's exchange rate can then be edited if required.  The idea being
that the currency table is not going to be continually adjusted and
will therefore only be approximately right.  Selecting a currency will
insert that last known exchange rate from the currency table but the
operator is free to adjust that figure for a specific item.  If the
operator uses the popUp to select a different currency the rate should
again be set to to a value from the currency table.

I need to set up the popUp Button so that it transfers its exchange
rate value to the payment record only when the popUp is changed.  If
the user edits the exchange rate directly, without touching to the
popUpButton I want the user's textfield entry to take precedence and
not be overridden by the popUp.

I think I can do this by binding a single line of javascript to the
popUp.  something like
onchange = "form.rate.value = value"

where the last "value" is the attribute bound to the value binding of
the popUp.

I know this is isn't quite right.  Can someone help me with the next
step?

Here's what I have:

Form1: WoForm {}

PopUpBotton1 : WOPopUpButton {
	list = currencyArray;
	item = currencyItem;
	displayString = currencyItem.abbreviation;
	selection = payment.currency;
	value = currencyItem. fxRate;
	onChange = "form.rate.value = value";   <--  this line is not correct
}

TextField1: WOTextField {
	value = payment.fxRate;
	name = "rate";
}



Denis Stanton
email@hidden
Home: +64 9 533 0391
mobile: +64 21 1433622
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.


References: 
 >Using javascript inside a WOPopup (From: Denis Stanton <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.