0

I have a form to update an entity called Equipment. This form must pass in the action the route '/' serial number of the equipment.

How can i pass the serial number of this entity?

This form is in a modal. See below:

<form
 name="editEquipmentForm"
 id="editEquipmentForm"
 class="form-horizontal"
 method="POST"
 action="/equipments/SERIALNUMBER"  <-- I need pass the serial here
>

I get the variable in another file called request.ejs. This file is included by the index.ejs, that has the modal.

Here's how i get the serialnumber:

function getEquipmentData(serialNumber) {
var serialNumber = serialNumber;
setEditInputs();
document.getElementById("serialnumber2").value = serialNumber;

$.ajax({
  url: "equipments/" + serialNumber,
  type: "get",
  success: function(response) {
    document.getElementById("sha1Curve2").value = response[0].sha1Curve;
    document.getElementById("equipmentName2").value =
      response[0].equipmentName;
    document.getElementById("position2").value = response[0].position;
    document.getElementById("idealRangeMin2").value =
      response[0].idealRangeMin;
    document.getElementById("idealRangeMax2").value =
      response[0].idealRangeMax;
  },
  error: function(xhr) {
    console.log(xhr);
  }
});}

This function is called when i open the modal.

Thanks for any tips.

1
  • can you show us full HTML of FORM Commented Dec 26, 2018 at 11:43

1 Answer 1

3

Try this:

document.forms.editEquipmentForm.action = '/equipments/' + serialNumber;

Or this:

var form = document.getElementById('editEquipmentForm');
form.action = '/equipments/' + serialNumber;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.