I am trying to implement this example on my website: http://jsfiddle.net/eDeQr/1/
The problem is that I need the $cp1 = 4;
variable to be global and not inside that function. As soon as I do that the function doesn't give any output in the second field.
This is what I want it to look like:
<script type="text/javascript">
function calc() {
var textValue1 = document.getElementById('input1').value;
var textValue2 = $cp1;
document.getElementById('output').value = textValue1 * textValue2;
};
</script>
The $cp1
variable should be global.