Jump to content

Conditionally Combine Multiple Fields


Recommended Posts

I have a form where users can add multiple line items to be researched. I've been asked to create field that lists all the items to view in a report. I put this in my form on Friday and it was working fine but when we were testing today, the fields are not working anymore.

<SCRIPT LANGUAGE="JavaScript">

function con1()
{
   var v1 = document.getElementById("EditRecordItem1").value;
   var v2 = document.getElementById("EditRecordItem2").value;
   var v3 = document.getElementById("EditRecordItem3").value;
   var v4 = document.getElementById("EditRecordItem4").value;
   var v5 = document.getElementById("EditRecordItem5").value;
   var v6 = document.getElementById("EditRecordItem6").value;
   var v7 = document.getElementById("EditRecordItem7").value;
   if (v1 !="" && v2 == "" && v3 =="" && v4 =="" && v5=="" && v6=="" && v7=="")
{
document.getElementById("EditRecordF14").value = v1;
}
 if (v1 !="" && v2 != "" && v3 =="" && v4 =="" && v5=="" && v6=="" && v7=="")
{
document.getElementById("EditRecordF14").value = v1 + ", " + v2;
}
 if (v1 !="" && v2 != "" && v3 !="" && v4 =="" && v5=="" && v6=="" && v7=="")
{
document.getElementById("EditRecordF14").value = v1 + ", " + v2 + ", " + v3;
}
 if (v1 !="" && v2 != "" && v3 !="" && v4 !="" && v5=="" && v6=="" && v7=="")
{
document.getElementById("EditRecordF14").value = v1 + ", " + v2 + ", " + v3 + ", " + v4;
}
 if (v1 !="" && v2 != "" && v3 !="" && v4 !="" && v5!="" && v6=="" && v7=="")
{
document.getElementById("EditRecordF14").value = v1 + ", " + v2 + ", " + v3 + ", " + v4 + ", " + v5;
}
 if (v1 !="" && v2 != "" && v3 !="" && v4 !="" && v5!="" && v6!="" && v7=="")
{
document.getElementById("EditRecordF14").value = v1 + ", " + v2 + ", " + v3 + ", " + v4 + ", " + v5 + ", " + v6;
}
 if (v1 !="" && v2 != "" && v3 !="" && v4 !="" && v5!="" && v6!="" && v7!="")
{
document.getElementById("EditRecordF14").value = v1 + ", " + v2 + ", " + v3 + ", " + v4 + ", " + v5 + ", " + v6 + ", " + v7;
}
}

document.getElementById("caspioform").onchange=con1;

</SCRIPT>

 

Link to comment
Share on other sites

  • 2 weeks later...

For item1 to 7 make sure you are having static ID for instance if any of them are cascading element the ID will follow with some numbers which is different on each load. To check you can right click on the element in your browser and select Inspect Element. If the ID has some extra numbers after it you need to refer it by name instead in this format:

 

var v1 = document.getElementsByName("EditRecordItem1")[0].value;

 

To see what error you are receiving, open the page in browser, click f12 to open developer tool and select console tab, reload the page and see what error message you are getting.

Link to comment
Share on other sites

  • 4 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...