I have a function which prints bar code and I want to make a click event, but when I am calling my function using javascript on click, its not working, please find the code below? I am able to view it on page without onclick. I want to call get_object(id)
If you copy-pasted it, you first need to change
onclick "get_object("110091")"
To
onclick="get_object('110091')"
You forgot the = sign, and you can not use double quotes " inside an attribute value (since they are already used for separating it)
your missing the = sign it should be onclick="get..."
Is your post mistyped, or is the "=" after "onclick" actually missing? Also, you should use single-quote inside the get_object() method, or this will not properly parse.
Your tag needs to read:
... onclick="get_object('110091')" ...
note both the equals sign, and using the alternate quote characters inside - as it is your use of double quotes both to enclose the attribute and to pass the function parameter will break.
Also, why use such a complicated get_object()
function? Your question is tagged HTML5
which AFAIK guarantees that getElementById()
will be available.
Your get_object function does nothing but return the DOM object using the id passed in - it doesn't draw any barcodes... It sounds to me like you want:
<button type="button" button data-theme="b" id="submit" onclick="DrawCode39Barcode(get_object('inputdata').innerHTML,0);return false;">theater</button>
精彩评论