0

This is my code:

    var Area = "000000002";
    <a class='button orange' id='proceed' onclick='testFunction("+Area+")' href='javascript:;'>Proceed</a>

Now when this value is sent to the next function i.e ....

    function testFunction(Area)
    {
    alert(Area)
    }

In this case I get the value 2....what i should be getting is 000000002....

So i guess it is not being sent as a string.

I need to know how to get the value 000000002 is the testFunction...

Thanks in advance...

3 Answers 3

2

Try this:

var Area = "000000002";
<a class='button orange' id='proceed' onclick='testFunction(&apos;"+Area+"&apos;)' href='javascript:;'>Proceed</a>
Sign up to request clarification or add additional context in comments.

Comments

0

You really don't want to do this "+Area+";

function testFunction(Area)
{
    alert(Area.toString())
}
var Area = "000000002";

<a class='button orange' id='proceed' onclick='testFunction(Area)' href='javascript:;'>Proceed</a>

Hope this helps...

Comments

-1
<button class="btn btn-success" type="submit" onclick="myFunction(<%=ppiid+","+price+","+"'"+pname+"'"%>)">add to cart</button> 

 function myFunction(x,y,z)
     {        
        document.getElementById("demo").innerHTML=x+" "+y+" "+z.toString();             
     }

<p id="demo"></p>

1 Comment

Format the Answer Properly other wise you will get more down votes

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.