# Automatic popup window refresh in Perspective label input component after clicking submit button

**URL:** <https://forum.inductiveautomation.com/t/automatic-popup-window-refresh-in-perspective-label-input-component-after-clicking-submit-button/90659>\
**Category:** Ignition\
**Tags:** ignition81, perspective\
**Created:** [May 21, 2024, 9:14am UTC](https://forum.inductiveautomation.com/t/automatic-popup-window-refresh-in-perspective-label-input-component-after-clicking-submit-button/90659 "2024-05-21T09:14:51Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![srinivasan\_s](https://avatars.discourse-cdn.com/v4/letter/s/eb9ed0/32.png) [@srinivasan\_s](https://forum.inductiveautomation.com/u/srinivasan_s)\
**Post date:** [May 21, 2024, 9:14am UTC](https://forum.inductiveautomation.com/t/automatic-popup-window-refresh-in-perspective-label-input-component-after-clicking-submit-button/90659/1 "2024-05-21T09:14:52Z")

</div>

I have a popup window that is going to add machine details in 4 text input component. After adding the data , when I click "add" button, it will add to DB. At the same time it should clear the entered details in the input component. How to achieve that?  
I have tried to initialize the component again with empty string, but not working. Please guide me to get this !

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [May 21, 2024, 9:45am UTC](https://forum.inductiveautomation.com/t/automatic-popup-window-refresh-in-perspective-label-input-component-after-clicking-submit-button/90659/2 "2024-05-21T09:45:17Z")

</div>

Post a nicely cropped screenshot of the view.  
Post your code and format it properly. See [Wiki - how to post code on this forum](https://forum.inductiveautomation.com/t/wiki-how-to-post-code-on-this-forum/77831).

---

<div class="post-metadata">

**Author:** ![srinivasan\_s](https://avatars.discourse-cdn.com/v4/letter/s/eb9ed0/32.png) [@srinivasan\_s](https://forum.inductiveautomation.com/u/srinivasan_s)\
**Post date:** [May 21, 2024, 9:53am UTC](https://forum.inductiveautomation.com/t/automatic-popup-window-refresh-in-perspective-label-input-component-after-clicking-submit-button/90659/3 "2024-05-21T09:53:21Z")

</div>

As instructed, Please refer to image

 ![Capture123456](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/6/e654d42c91466873837c971620a9eddce251e687.png)

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [May 21, 2024, 9:55am UTC](https://forum.inductiveautomation.com/t/automatic-popup-window-refresh-in-perspective-label-input-component-after-clicking-submit-button/90659/4 "2024-05-21T09:55:20Z")

</div>

And the code?

---

<div class="post-metadata">

**Author:** ![srinivasan\_s](https://avatars.discourse-cdn.com/v4/letter/s/eb9ed0/32.png) [@srinivasan\_s](https://forum.inductiveautomation.com/u/srinivasan_s)\
**Post date:** [May 21, 2024, 9:56am UTC](https://forum.inductiveautomation.com/t/automatic-popup-window-refresh-in-perspective-label-input-component-after-clicking-submit-button/90659/5 "2024-05-21T09:56:56Z")

</div>

```python
	machine_number=self.parent.parent.getChild("Site_SysFlexRepeater").props.instances[0].value
	machine_name=self.parent.parent.getChild("Site_SysFlexRepeater").props.instances[1].value
	process=self.parent.parent.getChild("Reason_UserFlexRepeater").props.instances[0].value
	product=self.parent.parent.getChild("Reason_UserFlexRepeater").props.instances[1].value
	ip=self.parent.parent.getChild("Site_SysFlexRepeater_0").props.instances[0].value
	if machine_number != '' and machine_name != '' and process != '' and product != '' and ip != '':
 		system.db.runPrepUpdate("INSERT INTO machine_master (machine_no, machine_name, ipaddress, process,product ) VALUES (?,?,?,?,?)", [machine_number, machine_name, ip, process,product])
 		self.parent.parent.getChild("Label").props.style.color = '#1E398D'
 		self.parent.parent.getChild("Label").props.text = "Machine Details Added Successfully"
 		try:
 			self.parent.parent.getChild("Site_SysFlexRepeater").props.instances[0].value='';
 		except:
 			pass;
 				
	else:
		self.parent.parent.getChild("Label").props.style.color = '#1E398D'
		self.parent.parent.getChild("Label").props.text = "Enter all the Fields"
		
			
	

```

Onclick Event-Create Button Component

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [May 21, 2024, 10:18am UTC](https://forum.inductiveautomation.com/t/automatic-popup-window-refresh-in-perspective-label-input-component-after-clicking-submit-button/90659/6 "2024-05-21T10:18:41Z")

</div>

1. Regarding your question title, the Label component is not an input. I suspect you mean the Text Area and Dropdown components.

2. To clear the input components you would have to add a line to clear each field. Something like,  
`self.parent.parent.getChild("Site_SysFlexRepeater").props.instances[0].value = ''`

General comments:

1. Form is messy. Vertical alignment is off. Inconsistent capitalisation. Yellow on dark blue button? Could arrange in two columns: labels and inputs.
2. The CREATE button should be disabled until all the fields are filled out. Then you don't need the `if ... else ...` stuff.
3. Using flex repeaters for two components makes life complicated for such a simple form.
4. You can avoid all the `parent.parent.getChild` by creating custom properties on the view to hold the input values.
  - On the view create a custom property for each input value.
  - Bind each input to its custom property. Make the binding bidirectional.
  - In your code you can now replace  
`machine_number=self.parent.parent.getChild("Site_SysFlexRepeater").props.instances[0].value`  
with  
`machine_number = self.view.custom.machine_num`  
This is much easier to read and will still work if the path changes when components are moved in and out of containers.  
To clear the input field value you would just write to the custom property.  
`self.view.custom.machine_num = ''`

5. Consider putting a binding on each input component's border color. Make it red until a valid input has been entered. This is common on web forms.

---

<div class="post-metadata">

**Author:** ![srinivasan\_s](https://avatars.discourse-cdn.com/v4/letter/s/eb9ed0/32.png) [@srinivasan\_s](https://forum.inductiveautomation.com/u/srinivasan_s)\
**Post date:** [May 21, 2024, 10:26am UTC](https://forum.inductiveautomation.com/t/automatic-popup-window-refresh-in-perspective-label-input-component-after-clicking-submit-button/90659/7 "2024-05-21T10:26:49Z")

</div>

Thank you for your valuable input. Will correct it. 😊

---

<div class="post-metadata">

**Author:** ![srinivasan\_s](https://avatars.discourse-cdn.com/v4/letter/s/eb9ed0/32.png) [@srinivasan\_s](https://forum.inductiveautomation.com/u/srinivasan_s)\
**Post date:** [May 21, 2024, 10:43am UTC](https://forum.inductiveautomation.com/t/automatic-popup-window-refresh-in-perspective-label-input-component-after-clicking-submit-button/90659/8 "2024-05-21T10:43:37Z")

</div>

Having issue. If I add self.parent.parent.getChild("Site\_SysFlexRepeater").props.instances[0].value = ' ' like this in inside 'if' condition, I need to again close the popup and open only clearing the data. I need to clear after entering the "Create " Button

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [May 21, 2024, 11:34am UTC](https://forum.inductiveautomation.com/t/automatic-popup-window-refresh-in-perspective-label-input-component-after-clicking-submit-button/90659/9 "2024-05-21T11:34:10Z")

</div>

The Flex Repeater component might only read parameters on first load. Changing them while open may not work.

Two options:

1. Use message handlers.
2. Simplify the arrangement and get rid of the flex repeaters.
