19eggs
19eggs

Reputation: 195

How to insert a variable value into javascript:(here)

I want to insert the value after ^ into javascript:DoRowAny(here)

var totalApps = 0^NOT_DECIDED~P~TUYTR78YT; //dynamically generated
var totalNumber = totalApps.split('^')[0];
var totalId = totalApps.split('^')[1];

var totalapp = '<a class="app" data-placement="top" data-original-title="' + totalNumber + ' in total."href="javascript:DoRowAny();" >' + totalNumber + ' not decided.</a>' ;

javascript:DoRowAny(totalId) // I thought this would work but it does not. Pure javascript not jquery.

<a class="tooltip-item action-reqd" data-placement="top" data-original-title="View 0 applications<br>requiring pre-decision action." target="_parent" href='javascript:DoRowAny("YES_DECIDED~YD~TPPEUR98UYD01");'>0</a>


function DoRowAny(id) // 
     {  
            document.getElementById('#inputOne').value=id;  //inserts the value of the id into the input
            document.getElementById('#buttonThree').click(); //and then clicks button 3
            return true;
            };

Upvotes: 1

Views: 87

Answers (1)

vikrant singh
vikrant singh

Reputation: 2111

Try this -

Use escaped '

var totalapp = '<a class="app" data-placement="top" data-original-title="' + totalNumber + ' in total." href="javascript:DoRowAny(\''+totalId+'\');" >' + totalNumber + ' not decided.</a>';

DEMO

Upvotes: 1

Related Questions