add prefixed text to textfield linked to multiple choice
Hi,
Brief intro: my name is Brit and I have founded a charity to give people with physical disabilities in The Gambia mobility.
I use Ninox for client registration, assessment and mobility aids needed.
Am often out in the field without internet and use the Ninox app on my phone. I've managed to create a database with a layout that works well on my phone but have 2 issues I would appreciate if anyone can help.
1
I use multiple choice for 'equipment' (see image)
For 'wheelchair regular', 'wheelchair full support' and 'child walker' during assessments measurements need to be noted (different for each equipment). I would want a textfield to show up with predefined text so only the measurements need to be added.
For example if 'wheelchair regular' is chosen it would show a text field with predefined text as below where I can add measurements after A, B, C, D
A hip B. up.leg C. un.leg D. back
A
B
C
D
I've created a textfield linked to the multiple choice options but can't manage to add the prefixed text. I've also tried with a button, but can't manage to get just the button to show up and the text field only when button is clicked.
2
DOB on my phone in the mobile app I can only use the calendar (with is not useful) and not type the DOB. Can't risk loosing all the data, any options?
Help much appreciated, thanks!
21 replies
-
what is the code in your button?
I don't think you need to worry about displaying/hiding the button. Once the code works you can put the code in the Trigger after update of the multiple choice field. then you can get rid of the button.
What are the field names that you are working with?
For the DOB, you can use a text field that has code in the Trigger after update that then sets the date field.
-
said:
When I check 'wheelchair regular' the button and textfield show up, but only if I click the button the predefined text will show.So you got this part to work. That is great.
You can modify your code to:
var CRLF := urlDecode("%0D%0A"); let textToAdd := "A B C D"; Measurements := if length(Measurements) != 0 then Measurements + CRLF end + textToAdd
Line 1, creates a variable to insert a carriage return or line feed. I use this in place of hard coding a carriage return which can make reading the code harder.
Lines 2 - 5, you know. You could replace all the carriage returns with CRLF so it all fits on 1 line.
Lines 6 - 9, adds a bit of logic to make sure you don't overwrite any text that is already in the Measurements field. So it adds a if statement to check the length of field Measurements and if it is NOT equal to zero then we add the contents of Measurements plus the variable CRLF then the added text variable.
Now on to your Display only if part of the button and text field.
You are using a multiple choice field so you can not just use a simple equal sign when searching the selections.
What is happening is Ninox creates an array of choices when you select more than 1 choice. If you open your multiple choice field you will see numbers next to each choice. Now if you create a new formula field and put it next to your multichoice field and put this in it:
numbers(Equipment)
and as you select choices you will see this field show all of numbers of the choices you select/deselect.
So how do you search for multiple selections? Well it would look something like:
let validEquipCode := [1, 2]; let xEquip := numbers(Equipment); count(xEquip[var e := this; count(validEquipCode[= e]) > 0]) > 0
Line 1, creates an array of choice numbers that you want the button to appear. You can reference your multichoice field to verify the choice numbers and replace the ones you want.
Line 2, makes an array of all of selection in the Equipment field
Lines 3 & 4, is the code that takes each selection from the Equipment field and checks if it exists (using the count() command) in the validEquipCode and if 1 or more of the numbers is returned then it will show the button.
Now the button will show/hide on multiple possible choices.
I'll let you digest this for now.
When you have a moment, take a look at my comments about relational DBs:
-
said:
In regards to DOB if I set it to textfield will I loose previously entered data? The DOB field is also linked to 2 other fields that calculate Age and Age group (child, adult, senior)I was not suggesting removing the DOB field. You would be adding a new field, let us call it 'EnterDate', then after you enter it it will update the DOB field with whatever data you enter.
Add a new text field, call it EnterDate, and another button then put this in the On click:
let step1 := split(EnterDate, "/"); let xDay := number(item(step1, 0)); let xMon := number(item(step1, 1)); let xYear := number(item(step1, 2)); DOB := date(xYear, xMon, xDay)
When you enter the date, it is assuming you will use a slash (/) between date data, i.e. day/month/year. It is also expecting a four digit year. If you don't use a slash then replace the slash in line 1. Do not use any other separator.
Line 1, converts the data from the EnterDate field into an array. Arrays are your friend.
Line 2, gets the data for day using the item() command and then converts is back into a number with the number() command
Line 3, gets the data for month using the item() command and then converts is back into a number with the number() command
Line 4, gets the data for year using the item() command and then converts is back into a number with the number() command
Line 5, sets the DOB date field using the date() command.
If everything works like you expect, then copy the code from the button to the Trigger after update of EnterDate and now when you enter the data then click out the DOB field will be updated.
-
said:
What I actually want is for the text field to only show up if the button is clicked and with the predefined text.To do this you need another field that tracks the show/hide status. You can make it a number field, then add the code to your button:
newNumberField := 1
Then in the Display only if of the Measurements field you would add:
newNumberField = 1
You can set the Display on if of the new field to be null then it will not show.
-
said:
the DOB Entry button does not need to be visible at any time as the Enter DOB field is visibleYou can modify the Display only if or move the button to a tab.
Content aside
- 6 mths agoLast active
- 21Replies
- 61Views
-
2
Following