Welcome, Guest
Username: Password: Remember me

TOPIC: Modify EndURL during Submit

Modify EndURL during Submit 1 year 2 months ago #95992

  • ohvelma
  • ohvelma's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 38
  • Thank you received: 1
  • Karma: 1
I want to adjust the End URL of a survey to pass the value of an radio question when the user submits a questionnaire.

Background: I am collecting medical history from users, and as part of that I am implementing a set of questions about relatives for a medical family history in a child survey that will be iteratively completed. I want to pass a list of relatives back and forth between the parent and child survey that I can use to populate a control in the parent survey so from the parent survey user can see what relatives they have already entered.

To start with the child survey end url looks like this:
... survey/index/newtest/Y/lang/en/sid/532617/token/{packet}

I want to modify it to contain something like this just before the submit:
... survey/index/newtest/Y/lang/en/sid/532617/rel/Mother/token/{packet}

The submit button in the navigator class looks like this:

<p class="navigator">
<input id="movesubmit" type="hidden" value="movesubmit" name="move"></input>
<button id="movesubmitbtn" class="submit" name="move2" value="Submit" onclick="javascript:document.limesurvey.move.value = 'movesubmit';" accesskey="l" type="submit">
</button>
</p>

So I think that when the button is clicked a "movesubmit" function somewhere fires, but I am not sure where to find that function and whether I would have access to it if I did.

IF I could figure out how to access and update the EndURL before the movesubmit happens, I wouldn't really need to know where it was, all the work would be done by the EndURL.

Ideally I would get this to work in 1.92 since our network has not upgraded to 2.0 as of yet.

Thanks for any advice you can give!

Carole
The administrator has disabled public write access.

Modify EndURL during Submit 1 year 2 months ago #96013

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4050
  • Thank you received: 740
  • Karma: 341
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.
The administrator has disabled public write access.

Modify EndURL during Submit 1 year 2 months ago #96042

  • ohvelma
  • ohvelma's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 38
  • Thank you received: 1
  • Karma: 1
Yes and no. What happens is it works the first time, but then when I return to the page I start getting relatives wrapped with html and it gets ugly. I want to revise the EndURL, I think the terminology is to add some query parameters, so that both the value I passed in AND the value selected in the radio control are returned. If I could just figure out how to access the EndURL via jQuery, I could revise it and return the right thing. BUT that seems to be hidden from me. When I examine the page's HTML, I do not see the EndURL at all. So I am not sure how to modify it. Maybe its a session variable.

I could spend a bunch of time documenting the issue, but what is the point if nobody will read it. If someone would promise to look at it (hint, hint) I could go into more detail.

If I just knew more about the EndURL I could probably figure it out myself. But I am not having much luck in my searches for info about it. :(

Carole
The administrator has disabled public write access.

Modify EndURL during Submit 1 year 2 months ago #96043

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4050
  • Thank you received: 740
  • Karma: 341
Unfortunately, you cannot edit the EndURL dynamically with JavaScript. It is generated at the server level so can only be modified in the survey-settings screen with placeholders.
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.
The administrator has disabled public write access.
The following user(s) said Thank You: ohvelma

Modify EndURL during Submit 1 year 2 months ago #96076

  • ohvelma
  • ohvelma's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 38
  • Thank you received: 1
  • Karma: 1
So I figured out what I was doing wrong, go me!

GOAL: Allow users to iteratively enter child surveys and return to a parent survey where a summary of child survey entries appears.

From the parent survey I wanted to pass the value from a femalerel textarea (Q2292) to a hidden textarea lastrel (Q2298) on the child survey.

From the child survey my goal was merge the selection from a radio element reltype (Q2296) and a hidden textarea lastrel (Q2298) to a textarea femalerel (Q2292) on the parent survey.

In the case of my application, a list of user relatives that have had medical history information entered on the child survey appear on the parent survey.

PARENT SURVEY LINK
So the parent survey's link to the child survey in a text display element fhlink (Q2291) became:

<a href="nmtstudy.limequery.com/index.php/?sid=93...amp;937638X415X2298=">Add Relative Cancer History</a>

And the parent survey group containing the link has jQuery code activating the click event of the link in the text display element fhlink (Q2291) to append the femalerel textarea (Q2292) to the end of the link:

<script>

jQuery(document).ready( function(){

$('#question2291 a').click(function(){
var myRef = $(this).attr('href');
var myRel = $('#answer532617X413X2292').val();
$(this).attr('href',trim(myRef) + trim(myRel));
});

});

</script>

CHILD SURVEY ENDURL

What wasn't working were attempts to modify the EndURL programatically via jQuery after the child survey was loaded.

What does work is a modified definition of the EndURL in the child survey:

nmtstudy.limequery.com/index.php/survey/...X2292/{reltype.shown} {lastrel}

Now both the radio button value and the text area are funneled into the femalerel textarea (Q2292) on the parent survey.

Note: I also attempted to concatenate the two element values inside curly brackets (which didn't work) like this: {reltype.shown lastrel}

Now that I have figured this all out, I am concerned with the ability of users to modify their answers entered in the child survey, so I may choose to ditch the child survey approach in favor of inserting elements as needed on the parent survey and store the results in a textarea as json to be unpacked to a relational database later. Anyone know of some good examples for that kind of thing?

Thanks!

Carole
Last Edit: 1 year 2 months ago by ohvelma. Reason: forgot to sign
The administrator has disabled public write access.

Modify EndURL during Submit 1 year 2 months ago #96078

  • ohvelma
  • ohvelma's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 38
  • Thank you received: 1
  • Karma: 1
Also, when the value of the radio element was too long, I had a truncation issue to deal with. I worked around that issue with shortened options, it works but I wouldn't consider it an optimal solution. Never did figure out why the returned EndURL returned a truncated value in reltype.shown.
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.131 seconds
Donation Image