+
1
|
list
|
skin
|
login
|
editor
α-wwwiki
::
input
user:none
(3287 bytes)
_h1 input _p See examples in [[console]], [[include]], [[angular]], [[raytrace]], [[extended_evaluator]], ... {input {@ id="A" type="text" placeHolder="enter a number" }} {input {@ id="B" type="text" placeHolder="enter a number" }} {pre {@ id="C" style="background:#ffe;"}.} {input {@ type="submit" value="compute hypothenuse" onclick="°° var hypo = function ( a, b ) { a = parseInt(a); b = parseInt(b); return Math.sqrt( a*a + b*b ); }; var A = getId('A').value; var B = getId('B').value; getId('C').innerHTML = hypo( A , B ); °°" }} {hr} {input {@ id="rA" type="radio" name="foo" value="A" }A} | {input {@ id="rB" type="radio" name="foo" value="B" }B} | {input {@ id="rC" type="radio" name="foo" value="C" }C} | {input {@ type="submit" value="which radio button is selected ?" onclick="°° var res = 'none'; if (getId( 'rA' ).checked) res = 'rA'; if (getId( 'rB' ).checked) res = 'rB'; if (getId( 'rC' ).checked) res = 'rC'; var which = getId(res); getId('which').innerHTML = (which != null)? which.value : res ; °°" }} It's : {span {@ id="which"}} {hr} {input {@ id="rD" type="checkbox" name="bar" value="0" }D} | {input {@ id="rE" type="checkbox" name="bar" value="0" }E} | {input {@ id="rF" type="checkbox" name="bar" value="0" }F} | _h2 code {pre °° {input {@ id="A" type="text" placeHolder="enter a number" }} {input {@ id="B" type="text" placeHolder="enter a number" }} {pre {@ id="C" style="background:#ffe;"}.} {input {@ type="submit" value="compute hypothenuse" onclick="•• var hypo = function ( a, b ) { a = parseInt(a); b = parseInt(b); return Math.sqrt( a*a + b*b ); }; var A = getId('A').value; var B = getId('B').value; getId('C').innerHTML = hypo( A , B ); ••" }} °°} _h3 a few other and better examples _h5 1) from page [[angular]] : _p Working with a JS code contained in the input operator {pre °° {input {@ id="input1" type="text" value="" placeholder = "Please, enter your name" onkeyup = "getId('yourName').innerHTML='Hello ' + getId('input1').value + ' !' "}}} {h1 {@ id="yourName"}} °°} _h5 2) from page [[extended_evaluator]] _p Working with a JS code embedded in a container in the page {pre °° First {input {@ type="submit" value="init evaluator" onclick="oo var js = document.createElement('script'); var input = getId('code').innerHTML; js.innerHTML = decode_html_entities(input); // < ,> document.head.appendChild( js ); this.value = 'OK, evaluator inited !'; this.disabled='disabled'; oo"}} then {input {@ type="submit" value="evaluate" onclick="do_evaluate()"}} {pre {@ id="output"}} {pre {@ id="code"}oo .... some JS code oo} °°} _h5 3) from page [[raytrace]] : _p Working with a JS code contained in an external (and local !) JS file {pre °° First {input {@ type="submit" value="include lambdaray" onclick="oo var js = document.createElement('script'); js.src = 'plugins/lambdaray.js'; document.body.appendChild( js ); this.value = 'OK, lambdaray is included !'; this.disabled='disabled'; oo"}} then {input {@ type="submit" value="render scene" onclick="RAY.doUpdate();"}} oo} °°}