Wednesday 31 May 2017

How to modify a link's href so it submits form

I am working on an web page which I am templating with EJS. Each row has its own form and a number of form elements (all disabled); row ends with a icon serves as a link.

What I want to do is when that icon is clicked, the icon changes to a 'tick' icon and have all form elements on that row gets enabled. So far so good...

However, after this transition, I want the link (now with a 'tick' icon) to be able to submit the form if clicked. I failed to do that.

Where I have the icon in the EJS template:

<a href="#" onclick="adjustActionIcons('<%=i%>')" id="link<%=i%>"><span class="glyphicon glyphicon-pencil" id="editIcon<%=i%>"></span></a>

The function called after the click:

function adjustActionIcons(id) {
document.getElementById("dropDown" + id).removeAttribute("disabled");
document.getElementById("Text" + id).removeAttribute("disabled");
document.getElementById("editIcon" + id).className = "glyphicon glyphicon-ok";
// ?????
}

How can I change the href attribute replaced by a form submit function/trigger? Or any other approach to achieve the same goal?



via Ben77

No comments:

Post a Comment