Jump to content
  • 0
DesiLogi

Update different Fields based on Virtual field value

Question

In a Single Record Update form I'm trying to update different fields based on the value of a Virtual field. The Virtual field is loading with and External Parameter (number value).

Depending on what value that Parameter is I need a specific field to update/change on when the 'Update' button is clicked. I don't want all fields to update, just a single specific field based on the value of the Virtual field. 

For example:

If Virtual1= 3 then update myField1="mytext"

If Virtual1=4 then update myField2="mytext"

If Virtual1=5 then update myField3="mytext"

Here's some code I'm working with but can't seem to get it right. It's in the footer of the Single Record Update form. 

<script>
function changeVal() {

var v_product = document.getElementByID("EditRecordcbParamVirtual1").value;

if(v_product=="3")
{
document.getElementById('EditRecordmyField1').value = "Not Activated"
}
else if (v_product=="4"){
document.getElementById('EditRecordmyField2').value = "Not Activated"
}
else if (v_product=="5"){
document.getElementById('EditRecordmyField3').value = "Not Activated"
}
document.getElementById('caspioform').onsubmit = changeVal;
</script>

I tried this without the 'else if' part (for just the first If=3) but still couldn't get it to work. It's probably just some syntax- any help would be greatly appreciated. 

Share this post


Link to post
Share on other sites

4 answers to this question

Recommended Posts

  • 0

Heres a great post on passing fields from virtual fields to regular fields. Hope this helps.

 

 

 

<SCRIPT LANGUAGE="JavaScript">
function concatenate()
{
var x = document.getElementById("cbParamVirtual5").value;
document.getElementById("InsertRecordSchoolName").value = x;
}
document.getElementById("caspioform").onsubmit=concatenate;
</SCRIPT>

Share this post


Link to post
Share on other sites
  • 0

I ended up using the above and some other code for if/then to get it to work. Here's the solution in case anyone else needs it:

 

<SCRIPT LANGUAGE="JavaScript">
function concatenate()
{

var productid = document.getElementById("cbParamVirtual1").value;

if (productid == 3){
var x = document.getElementById("cbParamVirtual2").value;
document.getElementById("EditRecordmyTextfield1").value = x;
}

else
if (productid == 1){
var x = document.getElementById("cbParamVirtual2").value;
document.getElementById("EditRecordmyTextfield2").value = x;
}

else
if (productid == 2){
var x = document.getElementById("cbParamVirtual2").value;
document.getElementById("EditRecordmyTextfield3").value = x;
}

else
if (productid == 4){
var x = document.getElementById("cbParamVirtual2").value;
document.getElementById("EditRecordmyTextfield4").value = x;
}

else
if (productid == 5){
var x = document.getElementById("cbParamVirtual2").value;
document.getElementById("EditRecordmyTextfield5").value = x;
}

else
if (productid == 6){
var x = document.getElementById("cbParamVirtual2").value;
document.getElementById("EditRecordmyTextfield6").value = x;
}

}

document.getElementById("caspioform").onsubmit=concatenate;
</SCRIPT>

 

Share this post


Link to post
Share on other sites

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
Answer this question...

×   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...