Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Set one column of an Array X-Scale to number and a second column to text?

  • miamiman
  • miamiman's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 8 months ago - 3 years 8 months ago #203244 by miamiman
Hello people.

I'm trying to get a two (2) column array on X-Scale with one column set to "text" and another set to "number"?

I can set both to text or both to number.

Does such an option or solution exist?
Last edit: 3 years 8 months ago by miamiman.
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 8 months ago #203258 by Joffm
Please, explain or show what you mean by

one column set to "text" and another set to "number"?

Do you want
two input fields, the second only accepts numbers?
validate the second column with something like "is_numeric(Q1_Y001_X002" and ..."

one input field, the second as dropdown like an arry(numbers)?
There are many solutions here to insert a dropdown into an array(text)


one input field, the second as checkbox like an array(numbers) with checkbox display?

Waiting for your answer

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • miamiman
  • miamiman's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 8 months ago - 3 years 8 months ago #203262 by miamiman
Yes, it's an array with two column answers.

• two input fields, the first only accepts text; the second only accepts numbers.
• validate the first column with place holder and default value of "N/A" as text
• validate the second with currency numbers and thousand separators like "is_numeric(Q1_Y001_X002" and ..." as number

Is this possible? Per my image file?


https://forums.limesurvey.org/forum/attachment/21286?download=1


Thank you!
Last edit: 3 years 8 months ago by miamiman.
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 8 months ago #203279 by Joffm
Unfortunately there is no image attached.

But doing it the easy way.

You cannot have a placeholder AND a presetted value.
So to preset the text column to "N/A" use a question of type equation to preset this column, like
{QCode_SQ001_X001="N/A"}
{QCode_SQ002_X001="N/A"}
{QCode_SQ003_X001="N/A"}
...

To validate the second column to currency (max. two periods), use a regular expression like
regexMatch('/^[-+]?[0-9]*\.?[0-9]{0,2}$/',self.sq_SQ001_X002) and regexMatch('/^[-+]?[0-9]*\.?[0-9]{0,2}$/',self.sq_SQ002_X002) and regexMatch('/^[-+]?[0-9]*\.?[0-9]{0,2}$/',self.sq_SQ003_X002) and ...





As I said, a really easy solution.
There may be others using javascript or even an inputmask.
Read here
forums.limesurvey.org/forum/can-i-do-thi...nk-sort-codes#192539

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • miamiman
  • miamiman's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 8 months ago #203358 by miamiman
Thank you, but so far I'm unsuccessful.

The array and the X-scale where I want to define the values is as follows.



Should I place your code in the X-Scale Condition per image below?



My apologies for not understanding where to place the code.
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 8 months ago #203376 by Joffm
As I said:

So to preset the text column to "N/A" use a question of type equation to preset this column, like
{QCode_SQ001_X001="N/A"}
{QCode_SQ002_X001="N/A"}
{QCode_SQ003_X001="N/A"}


So you create a question of type equation before your array with the above in the question text.
You have to adapt to your question code and subquestion codes.

And this validation you enter in the "question validation equation" in "Logic"

regexMatch('/^[-+]?[0-9]*\.?[0-9]{0,2}$/',self.sq_SQ001_X002) and regexMatch('/^[-+]?[0-9]*\.?[0-9]{0,2}$/',self.sq_SQ002_X002) and regexMatch('/^[-+]?[0-9]*\.?[0-9]{0,2}$/',self.sq_SQ003_X002) and ...


Again you have to use your subquestion codes.
As you may see, I named the x-axis "X001", "X002"

In this sample I revised the regex a bit.

File Attachment:

File Name: limesurvey...7659.lss
File Size:20 KB


Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 8 months ago #203405 by Joffm
And after you tested everything, you have to hide the question with the equation.

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 8 months ago #203408 by tpartner
To make it more user-friendly, here is a post that shows how to dynamically force numerics in an array-texts column.

- forums.limesurvey.org/forum/can-i-do-thi...question-type#174586

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • miamiman
  • miamiman's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 8 months ago #203458 by miamiman
Thank you. Having the sample helps immensely.
The topic has been locked.
  • miamiman
  • miamiman's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 8 months ago #203543 by miamiman
Just wanted to thank JOFFM again.

After many trials/errors, I finally understood the logic of setting up the question correctly.

Regards!
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose