This topic is locked
[SOLVED]

 javascript and 5.0

11/11/2008 8:13:16 AM
PHPRunner General questions
G
garethp authorDevClub member

Sorry to be a pain.

In 4.2 I use the followoing javscript on the add page inserted before the final </body></html> in the visual editor...

<script>{literal}

document.forms.editform.value_net_value.disabled=true;

var vv = document.editform.value_unit_price;

var ww = document.editform.value_quantity;

vv.onchange = vv.onkeyup =ww.onchange = ww.onkeyup =function() {

var qty = document.editform.value_quantity.value;

var unit = document.editform.value_unit_price.value;

document.editform.value_net_value.value =parseFloat(qty)*parseFloat(unit);}
{/literal}</script>


I can get this to work in 5.0 - where should I insert the code?
Many thanks
Gareth

Sergey Kornilov admin 11/11/2008

I recommend to check PHPRunner templates manual, section related to java script:

http://www.xlinesoft.com/phprunner/docs/smarty_templates.htm

G
garethp authorDevClub member 11/11/2008

Sorry - I have had look but am very confused how to achieve this.
Can you please offer further help?
Many thanks
Gareth

S
swanside 11/11/2008

Take out the

{literal}


It worked for me

G
garethp authorDevClub member 11/12/2008

Thanks for this and taking time to respond - this appears to have worked which is great.
I guess the problem is continuing to add this code in visual editor as the templates are therefore not kept clean and resulting in reset. Any idea how to do this using events?
Don't know about you but I am finding the change to div really hard - so much of my code now is not working. Don't really want to stock with 4.2 as 5.0 has brought in some extra cool features and new versions will do the same.

J
Jane 11/12/2008

Gareth,
Please publish your project on Demo Account and send to support@xlinesoft.com a URL to your pages along with instructions on reproducing this error.

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

G
garethp authorDevClub member 11/12/2008

Jane
I am not actually getting an error because of don't actually know where to put the javascript code.
Swanside has kindly suggested to remove the {literal} and he is correct that this works as before and the Javascript can be added using the visual editor - which is great in some respects.
However is there a way to do this without making ammendments in visual editor - I thought this is what is now avoided as much as possible in 5.0 to avoid reset problems.
Any help on this would be greatly appreciated as I have quite a lot of Javascript in use throught my site.
Gareth

S
swanside 11/12/2008

Just to mention, I was getting the same problem, it was Jane at first who told me about the {literal} part.
Swanny.

G
garethp authorDevClub member 11/12/2008

Thanks for that.

A
amuro 11/12/2008

I use this way

  1. include js file on template file
  2. your own code on the js file
    If the template file is reset, only re-write the code to include file.
    Hope any help <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=35042&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />

G
garethp authorDevClub member 11/13/2008

Amura
I think I like what you are saving. What code do you add in the visual editor to reference the js file and where do you add it?

Where do you store the js file?
This could be a nice solution
Thanks for comment

A
amuro 11/25/2008

For instance, the add page uses js file
put this code on add.htm, and myjsfile is under include category.

<head>

.....

<scripty src="include/myjsfile.js"></script>

....

</head>

G
garethp authorDevClub member 12/16/2008

Hi
I have entered a js file reference to the add page template to always include a javascript file on build.
However is ther a way within this js file to isolate code for only specfic add pages. For example I have 2 pages - parts and orders - which now both include a reference to the same js file.
I would like parts add page to apply only javascript code 1 contained within this file and orders add page to only apply javascript code 2 contained within the file.
I could do this with 2 js files on the visual editor but I want to be able include the js file reference in the template file to avoid rebuild problems.
Make sense?
Thanks for your help