I want to give a check to the check box in advance(予めチェックボックスにチェックを付与する)

Koki_Enomoto
Level 3

I want to give a check to the check box in advance(予めチェックボックスにチェックを付与する)

【英語/English】

It is a question about the form.

Is it possible to give a check to the check box beforehand based on the original site when accessing LP of the form from a certain site?

Example>

People who browse CT (Computed Tomography) related sites on medical device related sites want to check CT when accessing the form. (See the following figure)

【日本語/Japanese】

フォームに関する質問です。

あるサイトからフォームのLPへアクセスした際に、元のサイトに基づいて、予めチェックボックスにチェックを付与することは可能ですか?

例>

医療機器関連のサイトで、CT(Computed Tomography)関連のサイトを閲覧した人が、フォームにアクセスした際に、CTにチェックを付与しておきたい。(参照:以下の図)

pastedImage_0.png

3 REPLIES 3
SanfordWhiteman
Level 10 - Community Moderator

Re: I want to give a check to the check box in advance(予めチェックボックスにチェックを付与する)

Generally speaking:

MktoForms2.whenReady(function(form) {  

   var currentValues = form.getValues();  

   if( document.referrer.test(/computed-tomography/i) ) {

     form.setValues({

        Name_Of_Checkboxes_Field: [currentValues.Name_Of_Checkboxes_Field,"CT"].join(";")

     })

  }

});

Where Name_Of_Checkboxes_Field is the field on the form and CT is the value of the checkbox you want to pre-check.

But you'll have to be more precise about what you mean by "from a certain site."  The above code assumes you mean the immediate referring URL and that the string computed-tomography is in the URL, which are just guesses. You should probably have a developer involved so you don't have the wrong tests in place.

Koki_Enomoto
Level 3

Re: I want to give a check to the check box in advance(予めチェックボックスにチェックを付与する)

Thank you for answering.

SanfordWhiteman
Level 10 - Community Moderator

Re: I want to give a check to the check box in advance(予めチェックボックスにチェックを付与する)

OK, please mark as correct.