This topic is locked

How to run javascript

3/3/2008 6:02:05 PM
PHPRunner General questions
F
Fanta author

I have a one more question today.
I try to parse value from one listbox to another with doubleclick with javascript. I find few examples here on the forum, but none of them I can make to work, just to see how to work with javascript in PHPRunner. Can someone give a good example how to work with javascript?
For example I need is to somethinh like this:
<TD class=editshade_lb style="PADDING-LEFT: 10px"

width=250>{build_edit_control field="SomeValue" mode="add" value=$value_SomeValue} OnDoubleClick:"java script:DoSomethingWithWalue</TD></TR>
P.S. I'm trying to pass value from one listbox to another listbox with javascript.
Thanks in advance!

J
Jane 3/5/2008

Hi,
to add JavaScript code turn on HTML mode on the Visual Editor tab and add it at the end of page.

You can't add JavaScript handler directly to dropdown because it is generated in the include/commonfunctions.php file.

Here is a sample:

{literal}<script>

document.forms.editform.value_FieldName.OnDoubleClick=function()

{

//your code here

}

</script>{/literal}

F
Fanta author 3/5/2008

Thank you Jane.
Now to continue with my problem because it's still here.
I try to do how you wrote me, but it still does not working.
Then I try to put the script at the end, in the header, in the body, everywhere I could in Visual Editor tab, but it still does not work.
I do not now, where is the problem. I looked a few examples and posts from few members on forum which get the same advise as I and they also complain that the code does not work.
Is there any another way?
Also I try the experimental version of PHPRunner 4.2 (because of import function and possibilities).
I experiment with the same example for what I need PHPRunner. I use the Visual Editor choose for some field from which table I need data, that it be at least 30 rows multiline.
Then when I try to choose values from the listbox which build_edit_control created, it did not took them and save them, not even one of them, not even as he was doing to me in my previous post where you help me to solve the problem.
That is a litllebit bug in program.
It look,s from the answers that you have a long time experience with PHPRunner. You must be here from the beginning or you are the one of the creators of the program. Am I wrong? Because I think you now better than I who should now about this problem.

J
Jane 3/6/2008

Hi,
this code is just a sample.

You need to adapt it for your project.
It's difficult to tell you what's happening or actual code without seeing actual files,tables, etc..
You can publish your project on Demo Account and send a URL to your pages to [email=support@xlinesoft.com]support@xlinesoft.com[/email] along with your order number and instructions on reproducing this error.

I'll find what's wrong with your project inspecting it at Demo account site.

F
Fanta author 3/10/2008

Thank you Jane. If is necessary I will put my code on some demo site. But let's first try to find solutions of problem here, not only because of me, but because of everybody else who use this excellent program and maybe found themselves in similar problem.
So I will explain what I try to do first here.
In one of my forms I have make one of my dropdowns as multiline with 30 rows. It took values from my table (the database is MS SQL) and populate with about 2000 peaces of data (products).

The user which use this form then select which products he need. Because it is hard to user to control which value he choose between 2000 of them I made decision to make another listbox which will be populate how user make a DoubleClick in first listbox.
So the first listbox is created by Visual Editor (build_edit_control field) and the second listbox I created in the column throw Visual Editor HTML view on the right side of the first listbox.
The field from which I took values from table is called imeproizvoda. When I look at the source code I saw that the build_edit_control field created listbox like this:

<select size = "30" id="value_imeproizvoda" name="value_imeproizvoda[]" multiple >


The code for second listbox which I created and put in the column is:

<select name="chosen[]" id="linked" SIZE="30" MULTIPLE WIDTH=512 STYLE="width: 400px" ></select>


And than it should took the values from the second listbox and store them in my table in my database.
The Javascript code should transfer the values from first listbox to another. Here is the code:

{literal}<script language="javascript" type="text/javascript">

document.forms.editform.value_imeproizvoda.OnDoubleClick=function copyToList1();
function copyToList1()

{

var AvailableLB = document.getElementById("value_imeproizvoda");

var LinkedLB = document.getElementById("linked");
for (var i=0; i < AvailableLB.length; i++) {

if (AvailableLB.options[i].selected == true) {

LinkedLB.options[LinkedLB.length] =

new Option(AvailableLB.options[i].text,

AvailableLB.options[i].value);

AvailableLB.options[i] = null;

i=i-1;

}

}

return;

};
</script>{/literal}


I put this code at the end of the page as Jane say. This javascript code works on test page that I created when I try to work with him outside of PHPRunner.

F
Fanta author 3/10/2008

I finaly have solution. If anybody else need it, the example of code is here:

{literal}<script language="javascript" type="text/javascript">
document.forms.editform.value_imeproizvoda.ondblclick = function() {myfunction();};

function myfunction()

{

var AvailableLB = document.getElementById("value_imeproizvoda");

var LinkedLB = document.getElementById("linked");

for (var i=0; i < AvailableLB.length; i++) {

if (AvailableLB.options[i].selected == true) {
LinkedLB.options[LinkedLB.length] =

new Option(AvailableLB.options[i].text,

AvailableLB.options[i].value);

AvailableLB.options[i] = null;

i=i-1;
}

}

return;

}

</script>{/literal}