I have a side-by-side with three rows and three columns. Columns 1 and 2 need to collect integers, but column 3 needs to allow numbers (with decimals). I modified a bunch of code I found on here and know which line is helping but also not quite right for my needs. Any help modifying it would be great. My survey is already live and none of the stakeholders mentioned this requirement. However looking at the first three submissions I see the need for this.
The last row of code is where I am having issues but wanted to provide as much context of my code and variables as possible.
Qualtrics.SurveyEngine.addOnReady(function()
{
//laod the library
var $jq = jQuery.noConflict(); //always keep this
//disable editing first and third row
//first row pulls in historical information
//row three calcualtes totals for columns 1 & 3 (column 2 only shows a box for row 2)
$jq('.SBS1 input:eq(0)').attr("disabled",true);
$jq('.SBS1 input:eq(2)').attr("disabled",true);
$jq('.SBS3 input:eq(0)').attr("disabled",true);
$jq('.SBS3 input:eq(2)').attr("disabled",true);
//hide first and third row of second column (total visitors)
var qid=this.questionId;
$('QR~'+qid+'#3~1~1~TEXT').up('td').childElements().invoke('hide');
$('QR~'+qid+'#3~10~1~TEXT').up('td').childElements().invoke('hide');
//seetting the value 0 for all boxes if blank
$jq('.SBS1 input').each(function(){ //column 1
$jq(this).val(getVal($jq(this).val()));
});
$jq('.SBS2 input').each(function(){ //column 2
$jq(this).val(getVal($jq(this).val()));
});
$jq('.SBS3 input').each(function(){ //column 3
$jq(this).val(getVal($jq(this).val()));
});
//change the text boxes to numeric
//this works great for columns 1 & 2 that are counting people and needs to be integers
//column 3 counts units and those could be down to quarter hours it is wiping out the decimals when saving the data
//I think I need to change parseInt to Number but I don't want it to be a Number for all columns
function getVal(val){var num = parseInt(val); if(isNAN(num)) {num=0;} return num;};
Controlling Side-by-Side input type
Sign up
Already have an account? Login
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join.
No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Login with Qualtrics
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join. No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Login to the Community
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join.
No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Login with Qualtrics
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join. No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
