Pass Javascript Values to Document Properties

html:
<pre>
Spotfire Input Control linked to 'myDocProperty':
<span id='spotfireInputWrapper'>
<SpotfireControl id="c5314cd0a5cc466eb0e55f5e463ec324" />
</span>

Spotfire Label displaying current 'myDocProperty' value:
<SpotfireControl id="79f728c3651f4ee1bcc10f68732954f8" />

html input
<INPUT id="htmlInput" value='hello'/>
html button that triggers javascript:
<SPAN id=ok>ok</SPAN> 

</pre>

js:
//javascript function that transfers html input value to spotfire input property control
$('#ok').button().on('click',function(){
 var jsValue = $('#htmlInput').val()
$('#spotfireInputWrapper input').val(jsValue).blur()
})




Here is an example:

html:
<style>
#switchImageButton {
    background-image: url("https://www.inversoft.com/blog/wp-content/uploads/2013/03/On-and-Off-Switch.jpg");
    height: 300px;
    width: 178px;
    background-repeat: no-repeat;
    background-position-x: -173px;
    }
</style>

<div id='sfDocProp'>
'switchStatus' Document Property: <SpotfireControl id="sw17ch57a7u55p0tf1r3d0cum3n7p4093r7y" />
</div>


<div id='switchImageButton'></div>

js:
function setOnOff(){
//check if css position is showing the on image
var isOn  = $("#switchImageButton").css("background-position-x")=="-173px"

//toggle image portion
var pos = isOn?"-10px":"-173px"
$("#switchImageButton").css("background-position-x",pos)

//update spotfire (boolean) doc prop
$('#sfDocProp input').val(isOn).blur()
}

$('#switchImageButton').on('click',setOnOff)





No comments: