Javascript in a specific node while edit/add content

I’m really new in the use of Drupal 7.

I would like to create a form with 2 fields width_inch and with_cm where after the user insert the value automatically will be computed the other field.

I created template.php inside the theme directory (/ sites / all / themes / my_theme / template.php ):

<?php
function ayb_preprocess_node(&$variables) {
  if (isset($variable['node']) && $variables['node']->type == 'prova') {
	  drupal_add_js(drupal_get_path('theme', 'ayb') . '/js/convert.js');
  }
}
?>

Then I tried to write my js file in the Javascript directory ( / sites / all / themes / my_theme / js / convert.js ), but I could not understand what to write in. At this moment I am not able to show a simple javascript warning:

<script>
$( "#edit-field-width_inch-und-0-value" ).change(function() {
  alert( "Handler for .change() called." );
});
</script>

It’s mandatory to insert “<script>” or not? How must I call the field “width_inch”?

TNX in advance. Sorry for my bad english. Ilic

Drupal version: 


Source: https://www.drupal.org/taxonomy/term/4/feed