- Posts: 6
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
smiley face without radiobutton and submitting
- floccs
- Offline
- New Member
Less
More
12 years 4 months ago #70720
by floccs
Replied by floccs on topic smiley face without radiobutton and submitting
I think you can add the submit() at the end of the selectface() function
The topic has been locked.
- toma
- Topic Author
- Offline
- New Member
Less
More
- Posts: 11
- Thank you received: 0
12 years 4 months ago - 12 years 4 months ago #70721
by toma
Replied by toma on topic smiley face without radiobutton and submitting
Then form is submitted automatically. At least how I put it there.
OR (when it will wait for a while before submitting)
So selectface-function goes on before actually selecting anything.
Code:
function selectface(face) { $('.face').removeClass('selected'); $('#question66 input.radio:eq('+face+')').attr('checked', true); $('.num'+face).addClass('selected'); $('form#limesurvey').submit(); }
Code:
function selectface(face) { $('.face').removeClass('selected'); $('#question66 input.radio:eq('+face+')').attr('checked', true); $('.num'+face).addClass('selected'); setTimeout(function() { $('form#limesurvey').submit(); }, 500); }
So selectface-function goes on before actually selecting anything.
Last edit: 12 years 4 months ago by toma.
The topic has been locked.
- floccs
- Offline
- New Member
Less
More
- Posts: 6
- Thank you received: 0
12 years 4 months ago #70723
by floccs
Replied by floccs on topic smiley face without radiobutton and submitting
You can also remove the lines with removeClass and addClass since the form is submitted automatically and you don't need styling of the selected image
The topic has been locked.
- toma
- Topic Author
- Offline
- New Member
Less
More
- Posts: 11
- Thank you received: 0
12 years 4 months ago #70727
by toma
Replied by toma on topic smiley face without radiobutton and submitting
I am not sure did make myself clearly. Form submits itself before user clicks on a smiley face. So right now this (combination of two alternatives) doesn't work.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10115
- Thank you received: 3597
12 years 4 months ago #70730
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic smiley face without radiobutton and submitting
I don't understand why you need to combine the two solutions if you want to imediately submit the form and don't need the "selected" effects.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- toma
- Topic Author
- Offline
- New Member
Less
More
- Posts: 11
- Thank you received: 0
12 years 4 months ago #70731
by toma
Replied by toma on topic smiley face without radiobutton and submitting
Reason is that it would be nice, if images would be links so cursor would change above them.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10115
- Thank you received: 3597
12 years 4 months ago #70732
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic smiley face without radiobutton and submitting
You can do that with CSS:
Code:
#questionQQ label img { cursor: pointer; }
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- toma
- Topic Author
- Offline
- New Member
Less
More
- Posts: 11
- Thank you received: 0
12 years 4 months ago #70733
by toma
Replied by toma on topic smiley face without radiobutton and submitting
That is so true...
Thanks!
Thanks!
The topic has been locked.
- toma
- Topic Author
- Offline
- New Member
Less
More
- Posts: 11
- Thank you received: 0
12 years 4 months ago #70735
by toma
Replied by toma on topic smiley face without radiobutton and submitting
"Luckily" there is something else which doesn't work with this:
Scaling seems to be impossible (or at least it needs something that I cannot do). But with that another method it can be done, because I can put html code to that. Maybe some more experienced person can do same with this one also.
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready(function(){ $('#question61 label img').click(function(){ setTimeout(function() { $('form#limesurvey').submit(); }, 500); }); }); </script>
Scaling seems to be impossible (or at least it needs something that I cannot do). But with that another method it can be done, because I can put html code to that. Maybe some more experienced person can do same with this one also.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10115
- Thank you received: 3597
12 years 4 months ago #70736
by tpartner
"Scaling" has nothing to do with this. That would depend on what images you put in the labels.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic smiley face without radiobutton and submitting
????some more experienced person
"Scaling" has nothing to do with this. That would depend on what images you put in the labels.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- toma
- Topic Author
- Offline
- New Member
Less
More
- Posts: 11
- Thank you received: 0
12 years 4 months ago - 12 years 4 months ago #70738
by toma
Replied by toma on topic smiley face without radiobutton and submitting
With "some more experienced person" I meant that maybe some one else can do these things easily, but I cannot because I am not very experienced in these stuffs.
Anyway with first method I could do something like this (I haven't check if this is proper code, but maybe idea can be seen from this):
But now is time to enjoy weekend... If you like you can/may post more ideas etc, but I will continue this task on monday. Have a nice weekend, folks!
Anyway with first method I could do something like this (I haven't check if this is proper code, but maybe idea can be seen from this):
Code:
<div> <div style="width:30%; background-image: url(/../images/smiley1.);> <a href="javascript:selectface(0);"><img class="face num0" src="emptyimage" /></a> </div> <div style="width:30%; background-image:url(../images/smiley2.);> <a href="javascript:selectface(1);"><img class="face num1" src="emptyimage" /></a> </div> <div style="width:30%; background-image: url(/../images/smiley3.);> <a href="javascript:selectface(2);"><img class="face num2" src="emptyimage" /></a><br/> </div> </div> <script> function selectface(face) { $('.face').removeClass('selected'); $('#questionID input.radio:eq('+face+')').attr('checked', true); $('.num'+face).addClass('selected'); } $(document).ready(function() { $('#questionID .survey-question-answer ').hide(); $('#questionID .questionhelp ').hide(); selectface($('#questionID input.radio:checked').val() - 1); }); AND some script for submitting page after clicking smiley face... </script>
But now is time to enjoy weekend... If you like you can/may post more ideas etc, but I will continue this task on monday. Have a nice weekend, folks!
Last edit: 12 years 4 months ago by toma.
The topic has been locked.
- toma
- Topic Author
- Offline
- New Member
Less
More
- Posts: 11
- Thank you received: 0
12 years 4 months ago #70803
by toma
Replied by toma on topic smiley face without radiobutton and submitting
Ok.
Now I have this:
Well I haven't tried it on real survey, but it seems work fine (images are scaled and work like submit-buttons) thanks to you.
Next problem is that questionID is different every time I import this question to new survey. Is there something to do about it?
Now I have this:
Code:
<div style="width:100%;"> <div style="width:30%; float:left; margin-left: 2%; margin-right:1%"> <a href="javascript:selectface(0);" onClick="$('form#limesurvey').submit();"><img class="face num0" src="/kysely/hymio/naama3.png" width="100%" /></a> </div> <div style="width:30%; float:left; margin-left: 2%; margin-right:1%"> <a href="javascript:selectface(1);" onClick="$('form#limesurvey').submit();"><img class="face num1" src="/kysely/hymio/naama2.png" width="100%" /></a> </div> <div style="width:30%; float:left; margin-left: 2%; margin-right:1%"> <a href="javascript:selectface(2);" onClick="$('form#limesurvey').submit();"><img class="face num2" src="/kysely/hymio/naama.png" width="100%" /></a><br/> </div> </div> <script type="text/javascript" charset="utf-8"> function selectface(face) { $('.face').removeClass('selected'); $('#question66 input.radio:eq('+face+')').attr('checked', true); $('.num'+face).addClass('selected'); } $(document).ready(function() { $('#question69 .survey-question-answer ').hide(); $('#question69 .questionhelp ').hide(); selectface($('#question69 input.radio:checked').val() - 1); }); </script> <style> .face { border:0px solid white; } .selected { border:4px solid #cc0000; } </style>
Well I haven't tried it on real survey, but it seems work fine (images are scaled and work like submit-buttons) thanks to you.
Next problem is that questionID is different every time I import this question to new survey. Is there something to do about it?
The topic has been locked.