Unity c# multiple inputfields

I have several inputfields and I want to write data in them. How do I determine the focus so that the data goes into the right one? Right now my code is:

private InputField input1;
private InputField input2;

public void Receive(int x){
        //InputField1 & InputField2 are names coming from Unity
		input1 = GameObject.Find ("InputField1").GetComponent<InputField>();
		input2 = GameObject.Find ("InputField2").GetComponent<InputField>();

		if (input1.isFocused) {
			input1.text = x.ToString();

		}
		else if (input2.isFocused){
			input2.text = x.ToString();
		}
	}

Now the data goes nowhere.

Check the documentation.

You can do a foreach loop on a public array. Public allows the editor to show the variable in the inspector, so you can set the initial value; in this case, the reference to the InputField on your objects in the scene.

public InputField[] inputFields; 
..
foreach(InputField field in inputFields){
     if(field.isFocused()){
             // Do something
      }
 }