Willkommen, Gast
Benutzername: Passwort: Angemeldet bleiben:
  • Seite:
  • 1
  • 2

THEMA: How to add a button at end of a survey to go to an external URL?

How to add a button at end of a survey to go to an external URL? 1 Jahr 8 Monate her #91282

  • spt
  • spts Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 8
  • Karma: 0
Hello,

Does anyone know how to add a button at the end of a survey in order to go to an external URL?

I'm trying to change the source code, but was wondering if anyone has done this before.

Basically I'd like to add a "Preview" button next to "Submit" button at the last page of survey, such that when it's clicked, participants will be redirected to an external link (which will show the preview of current survey results in some format that we desire).

Thanks,
Anna
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: How to add a button at end of a survey to go to an external URL? 1 Jahr 8 Monate her #91283

  • helper
  • helpers Avatar
  • OFFLINE
  • Expert Lime
  • Beiträge: 126
  • Dank erhalten: 18
  • Karma: 0
How is your technical level? If you have some technical expertise, you may want to consider putting in another button in the SurveyRuntimeHelper.php (in Version 2.00+ Build 130116 the buttons start at about line 1074).
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: How to add a button at end of a survey to go to an external URL? 1 Jahr 8 Monate her #91284

  • spt
  • spts Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 8
  • Karma: 0
Thanks for your reply.

I've been looking at frontend_helper.php, in the surveymover() function, it makes more sense to me that I should add a button in the last if statement.

I do not see how we can add a button in the SurveyRuntimeHelper.php.

Maybe I'm wrong.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: How to add a button at end of a survey to go to an external URL? 1 Jahr 8 Monate her #91286

  • helper
  • helpers Avatar
  • OFFLINE
  • Expert Lime
  • Beiträge: 126
  • Dank erhalten: 18
  • Karma: 0
Good catch... seems there are actually a couple of methods that end a survey and they all have a little different method. For example, grep/search for the following term:

javascript:document.limesurvey.move.value = 'movesubmit';

You will find this at least three times within the codebase. Another alternative might be to use CSS to change content or append a static button to the existing button (I think that jQuery has a shortcut for this - charlie.griefer.com/blog/2009/09/17/jque...dding-form-elements/).
Letzte Änderung: 1 Jahr 8 Monate her von helper.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: How to add a button at end of a survey to go to an external URL? 1 Jahr 8 Monate her #91287

  • holch
  • holchs Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 2670
  • Dank erhalten: 322
  • Karma: 121
Can't you just include something on the end page on template level?
Have a look at the manual! It is a really valuable source for information. Here some helpful links:
Manual (EN) | Question Types | Question Attributes | Workarounds

If you found this answer helpful and it saved you some time please consider a donation to the project to keep Limesurvey going!
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: How to add a button at end of a survey to go to an external URL? 1 Jahr 8 Monate her #91289

  • helper
  • helpers Avatar
  • OFFLINE
  • Expert Lime
  • Beiträge: 126
  • Dank erhalten: 18
  • Karma: 0
Actually, if you are not concerned about having this link button on the same page as the submit you could put a static HTML button on the end message (Edit survey text messages). That would probably be the least painful :)
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: How to add a button at end of a survey to go to an external URL? 1 Jahr 8 Monate her #91314

  • tpartner
  • tpartners Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 4190
  • Dank erhalten: 787
  • Karma: 359
A couple of JavaScript solutions...

Assumptions:
- you are using LS 2
- you want the button on the last question page (not the "End" page)
- you want the link opened in a new window

1) If you want to do this for a single survey, set up your survey to use JavaScript and add the following script to the source of one of the questions on the last question page.
<script type="text/javascript" charset="utf-8">
	$(document).ready(function(){
		var buttonText = 'Review Answers';
		var url = 'http://someRedirectLink.com';
 
		$('#movesubmitbtn').before('<button id="movereviewbtn" type="button">'+buttonText+'</button>');
		$('#movereviewbtn').click(function() {
			window.open(url, '_blank');
		}).button();
	});
</script>

2) If you want do do it for several surveys using the same template, add this to the end of template.js:
$(document).ready(function(){
	if($('#movesubmitbtn').length > 0) {
		var buttonText = 'Review Answers';
		var url = 'http://someRedirectLink.com';
 
		$('#movesubmitbtn').before('<button id="movereviewbtn" type="button">'+buttonText+'</button>');
		$('#movereviewbtn').click(function() {
			window.open(url, '_blank');
		}).button();
	}
});
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
Der Administrator hat öffentliche Schreibrechte deaktiviert.
Folgende Benutzer bedankten sich: spt

Re: How to add a button at end of a survey to go to an external URL? 1 Jahr 8 Monate her #91345

  • spt
  • spts Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 8
  • Karma: 0
Hi Tony,

Thanks for your reply.

I've tried (1), it's successful.

What I need is (2) and I've done per your instruction above, i.e., adding the codes at the end of template.js (I am using 'default' template), but nothing changed. Do I need to setup any other things to make it work?

Thanks,
Anna
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: How to add a button at end of a survey to go to an external URL? 1 Jahr 8 Monate her #91346

  • tpartner
  • tpartners Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 4190
  • Dank erhalten: 787
  • Karma: 359
Do I need to setup any other things to make it work?
No, that should work as-is. I assume you are working in a copy of the default template - you can't modify the original.

Are you getting any JavaScript errors?
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: How to add a button at end of a survey to go to an external URL? 1 Jahr 8 Monate her #91354

  • spt
  • spts Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 8
  • Karma: 0
Hi Tony,

Thank you!!! It works now (after making a copy of the template).

For the external link, do you know if it's possible to pass parameters such as survey ID & participant's token in template.js, for example:

var url = 'http://someRedirectLink.com?sid={SID}&token={TOKEN}';

I've tried using this, not working so far, maybe I have to use different notations.

Thanks,
Anna
Der Administrator hat öffentliche Schreibrechte deaktiviert.
  • Seite:
  • 1
  • 2
Moderatoren: ITEd
Ladezeit der Seite: 0.216 Sekunden
Donation Image