You are viewing limited content. For full access, please sign in.

Question

Question

How can I add code to insert the current browser to a hidden field when a user opens a form?

asked on August 29, 2014

 I was wondering what I might be able to do so that when I have clients reporting problems with a form, that I could have a hidden field that will be in all the submissions that would indicate the browser used during that step by the user. 

 

If I can also get information about Javascript being enabled, that would also be great as well. 

 

I just want to have this information as it would help debug situations and determine what the weak link in a process might be. 

0 0

Answer

SELECTED ANSWER
replied on September 3, 2014

You could fill the field when it is not read-only.

 

$(document).ready(function () {
  if (!$('.userAgent textarea').attr('readonly')) {
        $('.userAgent textarea').val(window.navigator.userAgent);
    }
});

 

0 0

Replies

replied on August 29, 2014

There used to be a $.browser that allowed you to grab that information using jQuery, but it was deprecated a while ago. A lot of people now recommend using a library like  Modernizr 2.8.3.

0 0
replied on August 29, 2014

Interesting. I will take a look. 

 

are their any plans to add something in the future to forms? Has anybody done something like what I am asking?

0 0
replied on August 29, 2014

You can try window.navigator.userAgent.

0 0
replied on August 29, 2014

inside a field as the default value? I want to be able to see a submission in the results for a process and edit the page to show hidden fields that will give me this information if possible.

0 0
replied on August 29, 2014

It's JavaScript, not a variable, so you'll need to get the value into the field using the usual means.

0 0
replied on September 3, 2014

Your Javascript works, but what should I add as an if statement to test that this runs each time the form is loaded as a submission, but not when I look in the results panel? Can I maybe set it for a field if read-only since it absolutely cannot be read only unless it's already been submitted and being viewed in the results page?

0 0
replied on September 3, 2014 Show version history

You could fill the field during the initial form submission.

 

$(document).ready(function () {
    if ($('input[name="routingResumeId"]').val() == "") {
        $('.userAgent textarea').val(window.navigator.userAgent);
    }
});

 

0 0
replied on September 3, 2014

But I want the code to run whenever the form is submittable. That would make it so when they reopen the saved form that they do not cause the change. I want whenever the submission page is generated, that looking at it and showing a hidden field will enable me to see what browser they used when submitting the form.

0 0
SELECTED ANSWER
replied on September 3, 2014

You could fill the field when it is not read-only.

 

$(document).ready(function () {
  if (!$('.userAgent textarea').attr('readonly')) {
        $('.userAgent textarea').val(window.navigator.userAgent);
    }
});

 

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.