0

I developed a module to show an "End" button on the node edit form, and it works fine.

function renew_form_alter(&$form, &$form_state, $form_id) {
  $form['actions']['property_endlease'] = array(
    '#type' => 'submit',
    '#value' => t('End'),
    '#access' => TRUE,
    '#weight' => 15,
  );

  return $form;
}

I want that, when users click on that button, some fields are changed from jQuery code.

I tried the following code, but it doesn't show any alert, even though the form is submitted.

jQuery('#edit-property-end').click(function (event) {
  alert('');
});

I want to submit the form after the jQuery code is executed.

Does anybody have an idea on how to do this?

Thanks

1

Try this

   $form['actions']['property_endlease'] = array(
            '#type' => 'submit',
            '#value' => t('End'),
            '#access' => TRUE,
            '#weight' => 15,
            '#attributes' => array("onclick" => "javascript:test();"),

        );

and create a custom js

function test()  {
//your code 
}

Hope it will work

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.