View Full Version : How to swap & display two text field values?
I have two text fields (1st called FROM, 2nd called TO) and one button.
Enter a word in each of the text fields.
When the button is pressed I want text field 1 (FROM) to contain text field 2's (TO) value, and vice versa. The screen should show the values swapped.
Does anyone have a sample of how to do this? I'm stuck.
Sure, use javascript.
var fieldOne = document.getElementById(idOfFieldOne);
var fieldTwo = document.getElementById(idOfFieldTwo);
var tempValue = fieldOne.value;
fieldOne.value = fieldTwo.value;
fieldTwo.value = tempValue;
Something like that should work.
Correct answer... unfortunately, I wasn't clear in my question - apologies ;-)
I should have included that I'm writing the method in Objective-C on the iPhone.
Thanks.
Same principal should apply, just google the syntax. I don't know objective-C. I'm sure you'll do basically the same thing.
Ok, just to bring this to a close.
Being new to the iPhone SDK and Objective-C, I was missing the method to reload the view; my routine for swapping he variables was fine. However, I couldn't figure out how to refresh the display. Here's what was needed to reload the view:
[self reload];
{sigh} noob mistake, but thought I'd post out the resolution anyway.
vBulletin® v3.6.4, Copyright ©2000-2024, Jelsoft Enterprises Ltd.