参数列表后面的Uncaught SyntaxError:missing)

时间:2015-05-29 17:50:44

标签: javascript html

当我点击按钮时,我试图触发JavaScript功能, 但没有任何反应,我能想到的唯一错误信息是在JavaScript控制台中:

Uncaught SyntaxError: missing ) after argument list    vacAdmin:204

这是我的功能,我甚至没有第204行,我还检查了参数列表:

function editRecord(idVac, title, location, reference, duration, buisness, task, commencement, interest, contractType, salary, func, requirements, employmenttype, employmentlevel){

    var vacform = document.createElement("form");
    vacform.setAttribute("name", "form");
    vacform.setAttribute("method", "post");
    vacform.setAttribute("action", "/vacChangeBox");

    var vacancyId = document.createElement("input");
    vacancyId.setAttribute("type", "hidden");
    vacancyId.setAttribute("name", "vacancyId");
    vacancyId.setAttribute("value", idVac);
    var titleform = document.createElement("input");
    titleform.setAttribute("type", "hidden");
    titleform.setAttribute("name", "title");
    titleform.setAttribute("value", title);

    var locationform = document.createElement("input");
    locationform.setAttribute("type", "hidden");
    locationform.setAttribute("name", "location");
    locationform.setAttribute("value", location);

    var referenceform = document.createElement("input");
    referenceform.setAttribute("type", "hidden");
    referenceform.setAttribute("name", "reference");
    referenceform.setAttribute("value", reference);

    var durationform = document.createElement("input");
    durationform.setAttribute("type", "hidden");
    durationform.setAttribute("name", "duration");
    durationform.setAttribute("value", duration);

    var buisnessform = document.createElement("input");
    buisnessform.setAttribute("type", "hidden");
    buisnessform.setAttribute("name", "buisness");
    buisnessform.setAttribute("value", buisness);

    var taskform = document.createElement("input");
    taskform.setAttribute("type", "hidden");
    taskform.setAttribute("name", "task");
    taskform.setAttribute("value", task);

    var commencementform = document.createElement("input");
    commencementform.setAttribute("type", "hidden");
    commencementform.setAttribute("name", "comencement");
    commencementform.setAttribute("value", commencement);

    var interestform = document.createElement("input");
    interestform.setAttribute("type", "hidden");
    interestform.setAttribute("name", "interest");
    interestform.setAttribute("value", interest);

    var contractform = document.createElement("input");
    contractform.setAttribute("type", "hidden");
    contractform.setAttribute("name", "contractType");
    contractform.setAttribute("value", contractType);

    var salaryform = document.createElement("input");
    salaryform.setAttribute("type", "hidden");
    salaryform.setAttribute("name", "salary");
    salaryform.setAttribute("value", salary);

    var funcform = document.createElement("input");
    funcform.setAttribute("type", "hidden");
    funcform.setAttribute("name", "func");
    funcform.setAttribute("value", func);

    var requirementsform = document.createElement("input");
    requirementsform.setAttribute("type", "hidden");
    requirementsform.setAttribute("name", "requirements");
    requirementsform.setAttribute("value", requirements);

    var employmenttypeform = document.createElement("input");
    employmenttypeform.setAttribute("type", "hidden");
    employmenttypeform.setAttribute("name", "employmenttype");
    employmenttypeform.setAttribute("value", employmenttype);

    var employmentlevelform = document.createElement("input");
    employmentlevelform.setAttribute("type", "hidden");
    employmentlevelform.setAttribute("name", "employmentlevel");
    employmentlevelform.setAttribute("value", employmentlevel);


    vacform.appendChild(vacancyId);
    vacform.appendChild(titleform);
    vacform.appendChild(locationform);
    vacform.appendChild(referenceform);
    vacform.appendChild(durationform);
    vacform.appendChild(buisnessform)
    vacform.appendChild(taskform);
    vacform.appendChild(commencementform);
    vacform.appendChild(interestform);
    vacform.appendChild(contractform);
    vacform.appendChild(salaryform);
    vacform.appendChild(funcform);
    vacform.appendChild(requirementsform);
    vacform.appendChild(employmenttypeform);
    vacform.appendChild(employmentlevelform);
    vacform.appendChild(vacancyId);

    var csrf = document.createElement("input");
    csrf.setAttribute("type", "hidden");
    csrf.setAttribute("name", "${_csrf.parameterName}");
    csrf.setAttribute("value", "${_csrf.token}");
    //append crsf
    //apepend element
    vacform.appendChild(csrf);


    document.body.appendChild(vacform);
    //submit form
    vacform.submit();



}

该功能由此按钮触发:

<td><input data-vacIdEdit="${vac.id}" type="button" name="Bearbeiten" value="Edit" onclick="editRecord(${vac.getId()},${vac.getTitel()},${vac.getLocation()},${vac.getReferenceCode()},${vac.getDuration()},${vac.getBuisnessTravel()},${vac.getTasks()},${vac.getCommencement()},${vac.getInterestGroup()},${vac.getContractType()},${vac.getSalary()},${vac.getFunctionality()},${vac.getRequirements()},${vac.getEmploymentType()},${vac.getEmploymentLevel()});"></td>

2 个答案:

答案 0 :(得分:-1)

我在JS Fiddle上探索了代码,由于某种原因,似乎editRecord函数导致了问题。控制台指出单击该功能时未定义该功能。仍然不确定为什么会这样,但我希望找到问题对你有所帮助。 这是我用来处理这个问题的js小提琴。  JS Fiddle

<td><input data-vacIdEdit="${vac.id}" type="button" name="Bearbeiten" value="Edit" onclick="console.log(editRecord)"></td>

运行此代码会返回一个错误,指出editRecord未定义,表明editRecord函数未传输到HTML。

答案 1 :(得分:-1)

简单..

<button onclick="editRecord(&apos;${vac.getEmploymentType()} &apos;)">Click me</button>