Dynamic javascript arguments from php

This code

<button type="button" onclick="reuse_addr(addr' . $counter . ',addr' . $counter . 'b)">Reuse Addr</button><br>';

Produces this:

<button type="button" onclick="reuse_addr(addr1,addr1b)">Reuse Addr</button>

(i know the arguments need to be set-off with quotes)

This code:

<button type="button" onclick="reuse_addr('addr' . $counter . '','addr' . $counter . 'b')">Reuse Addr</button><br>';

Produces a syntax error.

This is the source code that I need:

<button type="button" onclick="reuse_addr('addr1','addr1b')">Reuse Addr</button>

How do I get single quotes around the arguments? What am I doing wrong?

Thx

This did the trick:

<button type="button" onclick="reuse_addr(\'addr' . $counter . '\',\'addr' . $counter . 'b\')">Reuse Addr</button><br>';

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.