Jump to content
  • 0

Save Value in Virtual List box and pass as Parameter on button click (not Submit)


DesiLogi

Question

I have a submission form where there's a choice aside from the normal 'submit new record' function (that's available too but the user can also go this other route). 

There is a Virtual Field that is a List Box. The user can select a single record from this List Box (not multiple records) and then click a button (not the Submit button) to go to a different datapage. I need to pass the Value of the Virtual List Box as a parameter in the button's url link but don't know how to 'save' that value on the Virtual Fields' 'change'. 

Does anyone know how to use the Virtual field's current value (probably using a variable from 'on change'?) as a parameter in a url? 

In this example Virtual 1 is a List Box that stores a numerical unique ID value for the selection. I need to pass that in the url as a parameter.

<div style="text-align: center;"><a href="../mypage?ExampleID=[@cbParamVirtual1]&otherfieldID=[@otherfieldID]" target="_self"><input class="cb_custom_btn" type="button" value="LINK" /></a></div>

 

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 1

Ok, I have this worked out now if anyone needs something similar. The example code below is getting the value of 3 Virtual Fields and storing them as variables. It also creates 2 'labels' for the text that delineates what they are. Then it puts it all together in a single variable and uses that at the end of the url and passes as parameters like normal Caspio functions. 

 

<div style="text-align: center;">

<input class="cb_custom_btn" type="button" onclick="myfuntion()" value="LINK" />


<script>
function myfunction(){ 
var v_virt = document.getElementsByName("cbParamVirtual1")[0].value;
var v_virtc = document.getElementsByName("cbParamVirtual2")[0].value;
var v_virtm = document.getElementsByName("cbParamVirtual3")[0].value;
var v_virtcn = "&FieldName2ID="
var v_virtmn = "&FieldName3ID="

var v_urlend = v_virt + v_virtcn + v_virtc + v_virtmn + v_virtm

window.location.replace( "../my-page?FieldNameID=" + v_urlend);

}
</script>

</div>

 

Link to comment
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...