Portada arrow Soporte arrow Forums
LimeSurvey Forums
Welcome, Guest
Please Login or Register.    Lost Password?
[done] Problems when using javascript in questions (1 viewing) (1) Guest
Go to bottom Favoured: 0
TOPIC: [done] Problems when using javascript in questions
#18803
raffe (User)
Fresh Lemon
Posts: 11
graphgraph
User Offline Click here to see the profile of this user
[done] Problems when using javascript in questions 2 Months ago Karma: 0  
Hello!

I tried something like this (with the latest LimeSurvey (or actually 5 days old)):
docs.limesurvey.org/tiki-index.php?page=..._Question_Validation

I read somewhere in the forum that there is a filter for security reasons which filters javascript input to prevent XSS attacs. Check config-defaults.php for a setting like "$filterxsshtml", copy this setting to config.php and disable the filterSo in config.php I put $filterxsshtml = false; as a last line before ?>.

So I go to LimeFitWin and source, there I have this:
<p>INFO:<br />
Text of the question you want to ask<br />
<SCRIPT LANGUAGE="JavaScript">

n1 = "1"; // n1, n2 interpreted as strings
n2 = "2";

n1 = parseInt( n1 ); // convert to integer type
n2 = parseFloat( n2 ); // convert to floating point type
sum = n1 + n2; // n1, n2 summed as numbers

document.write ( "n1 = " + n1 + "<BR>" );
document.write ( "n2 = " + n2 + "<BR>" );
document.write( "sum = " + sum + "<BR>" );

</SCRIPT></p>


I also tried with
Code:

<SCRIPT>

Not only with
Code:

<SCRIPT LANGUAGE="JavaScript">


When I edit the question (not in source mode) I only see
INFO:
Text of the question you want to ask

So that seems OK, but when I run the questions I see:
INFO:


n1 = "1"; // n1, n2 interpreted as strings
n2 = "2";

n1 = parseInt( n1 ); // convert to integer type
n2 = parseFloat( n2 ); // convert to floating point type
sum = n1 + n2; // n1, n2 summed as numbers

document.write ( "n1 = " + n1 + "
" );
document.write ( "n2 = " + n2 + "
" );
document.write( "sum = " + sum + "
" );

What do you think I have done wrong? Have I missed something in the config.php?
 
Logged Logged  
 
Last Edit: 2008/09/22 11:55 By Mazi.
  The administrator has disabled public write access.
#18848
Mazi (Moderator)
Moderator Lime
Posts: 3225
graph
User Offline Click here to see the profile of this user
Re:Problems when using javascript in questions... 2 Months ago Karma: 25  
First guess: Try setting $filterxsshtml = 0;

As far as I remember thiese switches use 0/1 to (de-)activate them. Maybe that makes a difference.
 
Logged Logged  
 
Best regards,
Mazi
______________________
Need help? I can: set up Limesurvey for you / create your survey / implement additional features / design your template / offer premium support -> Contact.
  The administrator has disabled public write access.
#19082
raffe (User)
Fresh Lemon
Posts: 11
graphgraph
User Offline Click here to see the profile of this user
Re:Problems when using javascript in questions... 2 Months ago Karma: 0  
Mazi wrote:
First guess: Try setting $filterxsshtml = 0;

As far as I remember thiese switches use 0/1 to (de-)activate them. Maybe that makes a difference.
I have now tried with both $filterxsshtml = false; and $filterxsshtml = 0; but I still don't get it to use the Javascript, instead it shows the text as before
INFO:


n1 = "1"; // n1, n2 interpreted as strings
n2 = "2";

n1 = parseInt( n1 ); // convert to integer type
n2 = parseFloat( n2 ); // convert to floating point type
sum = n1 + n2; // n1, n2 summed as numbers

document.write ( "n1 = " + n1 + "
" );
document.write ( "n2 = " + n2 + "
" );
document.write( "sum = " + sum + "
" );
I have also used the time to check the docs and forum to find clues, but I have failed to find the the right threads...

Any other guess? Do you need some more info from me? Just tell me and I will provide it.
 
Logged Logged  
 
Last Edit: 2008/09/20 23:54 By raffe.
  The administrator has disabled public write access.
#19090
klaci (User)
Fresh Lemon
Posts: 1
graphgraph
User Offline Click here to see the profile of this user
Re:Problems when using javascript in questions... 2 Months ago Karma: 0  
Hi,

I had the same problem as you. I tried this one:
docs.limesurvey.org/tiki-index.php?page=...rs_to_your_questions

and it didn't work, the <string> tags were always filtered.

I have LimeSurvey version 1.71+ (5498), I think this is the newest one.

I put the line
Code:

$filterxsshtml = false;
as a last line before
Code:

?>
in config.php as you wrote. Then I went to LimeFitWin and editing source code, I put the code again, and it works.
I did it on my local computer, I used EasyPHP 2.0 http://sourceforg.../project/showfiles.php?group_id=14045

I know, this is not to much, but I hope, perhaps this helps you to get some idea.

Bye
 
Logged Logged  
  The administrator has disabled public write access.
#19097
raffe (User)
Fresh Lemon
Posts: 11
graphgraph
User Offline Click here to see the profile of this user
Re:Problems when using javascript in questions... 1 Month, 4 Weeks ago Karma: 0  
At last it worked with
Code:

$filterxsshtml = false;

as a last line before
Code:

?>


But I needed to delete the old question (with javascript) and make a new one. The new question worked well with the script!

Thanks for your help!

PS. I will "litter" the wiki with some info about this

EDIT:
Here is my post in the wiki (feel free to change as you please ):
docs.limesurvey.org/tiki-index.php?page=...t_eg_JavaScript_etc_
 
Logged Logged  
 
Last Edit: 2008/09/22 09:34 By raffe.
  The administrator has disabled public write access.
#19110
Mazi (Moderator)
Moderator Lime
Posts: 3225
graph
User Offline Click here to see the profile of this user
Re:Problems when using javascript in questions... 1 Month, 4 Weeks ago Karma: 25  
Thanks for improving our manual!
 
Logged Logged  
 
Best regards,
Mazi
______________________
Need help? I can: set up Limesurvey for you / create your survey / implement additional features / design your template / offer premium support -> Contact.
  The administrator has disabled public write access.
Go to top