Jump to content
DesiLogi

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. 

Share this post


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>


 

Share this post


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. 

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