This topic is locked
[SOLVED]

 Where Would This Context Updating Javascript Go?

7/9/2013 10:35:11 AM
PHPRunner General questions
N
nohope4you author

I would like to have the following javascript applied to field1 and field2 in phprunner. Thank you!


<html>

<head>

<script>

function displayscript1()

{

document.getElementById("script").innerHTML="You are in the first field.";

}

function displayscript2()

{

document.getElementById("script").innerHTML="And now you are in the second field.";

}

</script>

</head>

<body>
<p id="script">You have not selected a field yet.</p>
Field1: <input type="text" onfocus="displayscript1()">
Field2: <input type="text" onfocus="displayscript2()">
</body>

</html>
Sergey Kornilov admin 7/9/2013

Use Javascript OnLoad event and here is the sample code that adds event handler:

http://xlinesoft.com/phprunner/docs/ctrl_on.htm

N
nohope4you author 7/9/2013

If there are no arguements, would it look like this? Also, would I put the onfocus=displayscript in the visual editor?
ctrl.on(focus,function displayscript1()

{

document.getElementById("script").innerHTML="You are in the first field.";

});
ctrl.on(focus,function displayscript2()

{

document.getElementById("script").innerHTML="And now you are in the second field.";

});



Use Javascript OnLoad event and here is the sample code that adds event handler:

http://xlinesoft.com/phprunner/docs/ctrl_on.htm

C
cgphp 7/9/2013

You need only the following code:

function displayscript1()

{

document.getElementById("script").innerHTML="You are in the first field.";

}
function displayscript2()

{

document.getElementById("script").innerHTML="And now you are in the second field.";

}
N
nohope4you author 7/9/2013

I ended up inserting the script portion as a php snippet and modifying the TextField.php file to make this work. Thanks everyone.



You need only the following code:

function displayscript1()

{

document.getElementById("script").innerHTML="You are in the first field.";

}
function displayscript2()

{

document.getElementById("script").innerHTML="And now you are in the second field.";

}