i am new to drupal and although i have managed to proceed a lot with my site using some very good modules such as webform, form builder, views etc now i am stuck with jquery.

I managed to build a calculated field for a webform by placing a file "webform-form-[node].tpl.php" under my theme folder and this file places a call to a jquery script.

Everything works fine till that point.
However, i have also created a menu link, which takes me to a view (uses the module "views") and displays all the submissions for that webform. There's a "edit" button which allows the user to edit that webform submitted fields. The problem is that on that "edit webform" page, the calculated field won't work - the jquery does not work.

Do i have to modify the files placed under the theme folder so that the calculated field works when editing the submitted webforms as well?



Jaypan’s picture

You probably did something wrong in your code, but since you didn't show it to us, it's pretty hard to tell you what's wrong.

A stab in the dark is that you included jQuery, which you don't need to do since core already includes jQuery. Including it two times will cause it to fail.

Checkout my Japan podcasts.
linkin21’s picture

Hi Jaypan,

thanks for the reply!

The file "webform-form-36.tpl.php" (the node for the webform is 36)
contains a call :

drupal_add_js(path_to_theme() .'/js/myScript.js');

and inside that js file, it's actually a pretty simple code like :

		jQuery('#edit-submitted-net-price').val(jQuery('#edit-submitted-list-price').val() * 0.5);

the problem is that, although the computed fields works smoothly in the original webform,
when i click the edit submission button (which is located under the view created for the submissions of this webform) the computed field no longer populates in case i change the list price.

In case you need any more information let me know please.

Thanks again,

Jaypan’s picture

Alright, it's good you are not including jQuery. Your code as it is looks fine. But I'm guessing the computed field script has a function that needs calling once you've updated the price. You'll have to go through that script to see if you can find out which function it is.

Checkout my Japan podcasts.
linkin21’s picture

ok, i got it, however i believe i'm doing something wrong with the files that are called when editing the submission.

To be more specific, the file "webform-form-36.tpl.php" is called properly when i click the menu link to submit the webform for the first time (link is "[mysite]/node/36")
But when i click the link to edit an already submitted webform (link is "[mysite]/node/36/submission/20/edit") the file "webform-form-36.tpl.php" is not called at all, hence the js script that i wrote will not work then.

Any ideas?

linkin21’s picture

ok, i found it...was pretty simple,

the administration theme was set to seven, instead of garland which i was using.

I reset it to "default" and now the jquery code works smooth when i edit the submissions.

Just sharing it in case it helps anyone in the future!