i have defined the following JavaScript:-
<script type="text/javascript">
var html = ' ';
var i = 1 ;
if ( "#variable.1#" != null) {
html += '<div><a href="/Service1.svc/vf/img?imgid=#variable.1#" >"View Page" + i </a></div>';
i =i +1;
}
if ( "#variable.2#" != null) {
html += '<div><a href="/Service1.svc/vf/img?imgid=#variable.2#"> "View Page" i </a></div>';
i = i=1;
}
if ( "#variable.3#" !=null) {
html += '<div><a href="/Service1.svc/vf/img?imgid=#variable.3#" >"View Page" + i </a></div>';
i = i+1;
}
document.write(html);
</script>
but the output of the above javascript incase all the variables are not null will be:-
"View Page" + i
"View Page" i
"View Page" + i
so how i can force the output to be External Intigration Images
View Page 1
View Page 2
View Page 3
采用
html += '<div><a href="/Service1.svc/vf/img?imgid=#variable.3#" >View Page '+i+'</a></div>';
You need to format your strings as follows:
html += '<div><a href="/Service1.svc/vf/img?imgid=#variable.3#" >"View Page" ' + i + '</a></div>'
This will take the value of i
and append it into the string, not i
itself.
As an additional bit of information, keep in mind that in JavaScript when a string is added to an integer, the integer is parsed as a string rather than the inverse. As is noted in the comment,
var answer = 1 + 1 + "1"
// answer = 21, not "111" and not 3
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.