javascript get clicked link id and compare it with a string -


I am new to javascript, please help me please!

I have these four links:
& lt; An id = "user name" href = "javascript: showEditTextBox (this.id)" & gt; & Lt; / A & gt; & Lt; An id = "business" href = "javascript: showEditTextBox (this.id)" & gt; & Lt; / A & gt; & Lt; A id = "country" href = "javascript: showEditTextBox (this.id)" & gt; & Lt; / A & gt; & Lt; An id = "industry" href = "javascript: showEditTextBox (this.id)" & gt; & Lt; / A & gt;

And I have a div, element with AP and form. P ID: id = "editHeader". What I want to do, to change P value, was clicked on the basis of that link. So I want to compare the ID value of the link clicked with the string:

My function is such, but it does not work:

  function showEditTextBox ( Id) {if (id == "userName") document.getElementById ("editHeader"). innerHTML = 'Change User Name'; Else if (id == "occupation") document.getElementById ("editHeader"). innerHTML = 'change business'; else if (id == "country") document.getElementById ("editHeader"). innerHTML = 'change country'; else if (id == "industry") document.getElementById ("editHeader"). innerHTML = 'Change Industry'; }    

You should use the # as href and onclick events. This way. Otherwise your javascript is correct.

The person working here is

    

There will be a good effect for your anchor tag, href = "# editHeader" so that the window is trying to change the type of

  & lt; an id = "industry" href = "# edit headers" onclick = "showEditTextBox (this.id)" & gt; Industry & lt; / A & gt;    

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -