Hi,

I am repeatedly getting "missing ) after argument list" in firefox.

hash_a is a variable.

$("#details_a").append("</br>"+"Enter Name "+"<input type='text' id='myText' />"+"<input type='button' id='theSubmitButton' value='Edit Name' onclick='edit_data("+hash_a+")\'\'>");

Thanks.

Dani AI

Generated

Short expert note: the Firefox error "missing ) after argument list" is a JavaScript parse error — most often it means the generated inline handler (or the surrounding script) has mismatched quotes or parentheses. Earlier replies already flagged escaping and string-construction as likely culprits (, ) and also pointed out that the real syntax problem can be on an earlier line (). The safest approach is to stop building complex markup with quoted concatenation and avoid inline onclick handlers.

Quick diagnostics:

  • Dump the exact string passed to append with console.log(...) and copy it into the console to reproduce the parse error.
  • Inspect the inserted node in DevTools to see the actual onclick attribute (unescaped characters will show up there).
  • Print JSON.stringify(hash_a) to reveal embedded quotes/backslashes that would break an inline handler.
    The console line number points to where the parser failed; if that line looks fine, scan earlier lines for unmatched parentheses or quotes.

Safer fixes (avoid inline handlers; attach data and bind events):

var $label = $('<span>').text('Enter Name ');
var $text = $('<input>', { type: 'text', id: 'myText' });
var $btn = $('<button>', { id: 'theSubmitButton', text: 'Edit Name' })
  .data('hash', hash_a)
  .on('click', function () {
    edit_data($(this).data('hash'));
  });
$('#details_a').append($label, $text, $btn);

Event delegation for dynamically added buttons:

$('#details_a').on('click', '#theSubmitButton', function () {
  edit_data($(this).data('hash'));
});

If inline construction is unavoidable, serialize the argument so inner quotes are escaped:

var safeArg = JSON.stringify(String(hash_a));
var html = '<input type="button" onclick="edit_data(' + safeArg + ')" value="Edit Name">';

Notes: ’s cleaned concatenation helps, but programmatic element creation or serialization (via JSON.stringify or encodeURIComponent) prevents fragile quoting bugs and is the recommended fix. Running a linter or opening the file in a JS-aware editor will also catch stray unmatched brackets that sometimes mislead the runtime error location.

Recommended Answers

All 5 Replies

At the end of the statment you are escaping the two single quotes. I think that you only need one of them to complete the onclick code and I do not see anywhere else in the code where the single quote is escaped.

$("#details_a").append("</br>"+"Enter Name "+"<input type='text' id='myText' />"+"<input type='button' id='theSubmitButton' value='Edit Name' onclick='edit_data("+hash_a+")'/>");

I am still getting the same error.

Techie,

Try building your HTML string like this:

var strArray = [
	"</br>",
	"Enter Name ",
	"<input type='text' id='myText' />",
	"<input type='button' id='theSubmitButton' value='Edit Name' onclick='edit_data(",
	hash_a,
	")'/>"
];
$("#details_a").append(strArray.join(''));

The line number in the error message will give you a better clue.

There may be an apostrophe in hash_a , which is the same as single quote. If so then try either:
a) swapping double-quotes for single and vice versa.
b) passing escape(hash_a) to edit_data then unescape(...) inside the function.

Airshow

Hi,

I am repeatedly getting "missing ) after argument list" in firefox.

hash_a is a variable.

$("#details_a").append("</br>"+"Enter Name "+"<input type='text' id='myText' />"+"<input type='button' id='theSubmitButton' value='Edit Name' onclick='edit_data("+hash_a+")\'\'>");

Thanks.

$("#details_a").append(
"<\/br>"+
"Enter Name "+
"<input type='text' id='myText' \/>"+
"<input type='button' id='theSubmitButton' value='Edit Name' onclick='edit_data("+
hash_a+
")'\/>");

Are you sure that the error is actually occurred in this line? Could it possibly be from previous lines (incorrect parentheses matching)?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.