Jump to content

copy virtual field value to field in submission form


Recommended Posts

Does anyone know the adjustment for this code to work? I'm trying to copy the value of a Virtual field (drop down)  to a regular text field, on a button's click.

 

Here's the code I'm working with:

<div style="text-align: center;">
<input class= "cb_custom_btn" type="submit" onclick="myfunction()" value="Submit" />
 
<script>
function myfunction()
{

var virtualval = document.getElementByID("cbParamVirtual4").value;
document.getElementByID("InsertRecordMyFieldName").value = virtualval;
}
</script>
</div>

I'd also tried the ElementsByName with [0] for cascading values but that doesn't work either..

What's weird is I've used code similar to this for the same purpose with no problem so I must be missing some minute detail. Any help would be greatly appreciated. 

Link to post
Share on other sites
On 3/4/2017 at 9:09 AM, DesiLogi said:

Does anyone know the adjustment for this code to work? I'm trying to copy the value of a Virtual field (drop down)  to a regular text field, on a button's click.

 

Here's the code I'm working with:


<div style="text-align: center;">
<input class= "cb_custom_btn" type="submit" onclick="myfunction()" value="Submit" />
 
<script>
function myfunction()
{

var virtualval = document.getElementByID("cbParamVirtual4").value;
document.getElementByID("InsertRecordMyFieldName").value = virtualval;
}
</script>
</div>

I'd also tried the ElementsByName with [0] for cascading values but that doesn't work either..

What's weird is I've used code similar to this for the same purpose with no problem so I must be missing some minute detail. Any help would be greatly appreciated. 

I would recommend separating html and java script. Also you should use getElementById instead of getElementByID.

Try using html code in html block:

<div style="text-align: center;">
<input type="submit" onclick="myfunction()" value="Submit" />
</div>

And the following script in the footer:

<script>
function myfunction()
{

var virtualval = document.getElementsByName("cbParamVirtual4")[0].value;

document.getElementById("InsertRecordMyFieldName").value = virtualval;
}
</script>


 

Link to post
Share on other sites

Hi Mathilda,

Thanks very much for the help with that- it works nicely. 

That said, the function I'm trying to work out as morphed since I posted this- I've put it on a different page, if you'd like to take a look. This thread was a question on a specific part of what I'm trying to do- as I've found other limitations (of my own ability with js) I've tried to lay out the whole process there. 

Link to post
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...