Show TWO new form fields dynamically | Community
Skip to main content
July 11, 2013
Solved

Show TWO new form fields dynamically

  • July 11, 2013
  • 2 replies
  • 1097 views
I want to expand my form dynamically showing TWO new fields.

I currently use the java (link below) in order to show just ONE extra field. I'm no java expert but would love to know how I can add a second field to the java that I'm currently using.

http://community.marketo.com/MarketoArticle?id=kA050000000KyqqCAC

Thanks
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by
I think you'd just copy part of it again and change the field names. So you'd have two blocks like there are below, but change the field names and the variable names (e.g. websiteRow):

var websiteRow = $jQ("#Website").parents("li:first");
  var websiteField = $jQ("#Website");

   // when the triggering field changes...
  $jQ("#Yesorno").change(function() {
    var value = this.value;

     // when "Yes", show the dynamic field and make it required
     // when "No", hide the dynamic field
    switch(value)
    {
      case "Yes":
         websiteField.addClass("mktFReq");
         websiteRow.addClass("mktFormReq").slideDown();
         break;

      default:
         websiteRow.removeClass("mktFormReq").slideUp();
         websiteField.removeClass("mktFReq");
    }
  }).change();


2 replies

Accepted solution
July 11, 2013
I think you'd just copy part of it again and change the field names. So you'd have two blocks like there are below, but change the field names and the variable names (e.g. websiteRow):

var websiteRow = $jQ("#Website").parents("li:first");
  var websiteField = $jQ("#Website");

   // when the triggering field changes...
  $jQ("#Yesorno").change(function() {
    var value = this.value;

     // when "Yes", show the dynamic field and make it required
     // when "No", hide the dynamic field
    switch(value)
    {
      case "Yes":
         websiteField.addClass("mktFReq");
         websiteRow.addClass("mktFormReq").slideDown();
         break;

      default:
         websiteRow.removeClass("mktFormReq").slideUp();
         websiteField.removeClass("mktFReq");
    }
  }).change();


July 11, 2013
Thanks, Erik. I was able to get it to work.