Click here to Skip to main content
15,880,503 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hey, I'm trying to trigger a JavaScript function with a button, but it doesn't work.
The only error I managed to figure out from the Chrome JavaScript console is this one :

Uncaught SyntaxError: missing ) after argument list         vacAdmin:204


It also seems that the function doesn't get recognized.

Well and this is my function :

JavaScript
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);
        vacancyId.setAttribute("value", title);
        vacancyId.setAttribute("value", location);
        vacancyId.setAttribute("value", reference);
        vacancyId.setAttribute("value", duration);
        vacancyId.setAttribute("value", buisness);
        vacancyId.setAttribute("value", task);
        vacancyId.setAttribute("value", commencement);
        vacancyId.setAttribute("value", interest);
        vacancyId.setAttribute("value", contractType);
        vacancyId.setAttribute("value", salary);
        vacancyId.setAttribute("value", func);
        vacancyId.setAttribute("value", requirements);
        vacancyId.setAttribute("value", employmenttype);
        vacancyId.setAttribute("value", employmentlevel);

        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();



    }



The function get triggered by this button :

HTML
<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>


Any suggestions what could be wrong ?

Thanks in advance
Posted
Updated 29-May-15 12:35pm
v2
Comments
Sergey Alexandrovich Kryukov 29-May-15 17:14pm    
In what line? What is the problem, to figure out bracket balance? :-)
—SA
DatPrettyUrkel 29-May-15 18:37pm    
I thin the editRecord function doesn't get recognized or something like that. Either that or there is something wrong with the setAttribute methods. A quick question: isn't it possible to add multiple attributes to an element?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900