473,545 Members | 2,776 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

including parameters in innerHTML

Claus Mygind
571 Contributor
In the code below I want to include the values of an array that only exist in the function where this code is located. But I get the following error:

missing ; before statement

td.innerHTML = '<input type="button" ...rue,'+aRetur n[0]+','+aReturn[1])+';">';\n
As shown in the code below I try to add the values of the array elements by putting them outside the single ' quote delimiter for the innerHTML. I have also tried putting them right in the string, but then the array is not recognized when the button is clicked.

What would be the correct syntax?

Expand|Select|Wrap|Line Numbers
  1.  
  2.  tr = tbody.insertRow(tbody.rows.length);
  3.  td = tr.insertCell(tr.cells.length);
  4.  td.setAttribute("align", "center");
  5.  td.innerHTML = '<input type="button" value="Continue" onclick="showPopSearch();validateUser(true,'+aReturn[0]+','+aReturn[1])+';">';
  6.  
Jan 12 '09 #1
1 3170
Claus Mygind
571 Contributor
I see my mistake. the ) is not in the literal string.

Expand|Select|Wrap|Line Numbers
  1. td.innerHTML += '<input type="button" value="Continue" onclick="showPopSearch();validateUser(true,'+aReturn[0]+','+aReturn[1]+');">';
  2.  
Jan 12 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

7
49561
by: Pavils Jurjans | last post by:
Hallo, I have been programming for restricted environments where Internet Explorer is a standard, so I haven't stumbled upon this problem until now, when I need to write a DOM-compatible code. The question is about best practices for passing parameters to an event function. I have, say, the following HTML:
6
1927
by: mr_burns | last post by:
hi, is it possible to have a string variable to contain new lines. i tried the following but it didnt work: var_string = '<h1>Title</h1> <img src="image.gif> <p>Body text</p>'; i know that html will display the same if i was to write the above
3
12468
by: N. Demos | last post by:
How do you dynamically assign a function to an element's event with specific parameters? I know that the code is different for MSIE and Mozilla, and need to know how to do this for both. I have the following event handler functions defined and need to assign them to table elements (<TD>) created dynamically in another function. ...
4
6542
by: RobG | last post by:
I know you aren't supposed to use innerHTML to mess with table structure, but it seems you can't use it just after a table without damaging the containing element. I added a table to a div using createElement methods, then added a bit of extra text using innerHTML, only to find most of the attributes removed from the table. Below is a...
9
8641
by: Hallvard B Furuseth | last post by:
Why does the FAQ (Q 4.15) recommend innerHTML when so many here say one should use createElement(), replaceChild() etc? Also, why does the "Alternative DynWrite function" at <http://www.jibbering.com/faq/faq_notes/alt_dynwrite.html> need such a lot of tests to find out if innerHTML assignment actually works, instead of just inserting...
1
14944
by: Pablo | last post by:
Dear all, I have a website where I need to fill its contents after retrieving some data from another system (not a DB, but you can think like it). I know the nature of the data, but the order that it is retrieved is random, and there is no way to order it. Therefore, it is giving me some pain to produce the html code. I was thinking of...
6
7222
by: Rob | last post by:
Hello, I'm sure this has come up before. I have need for a collection of all elements/objects in an HTML document that have any kind of an attribute (HTML or CSS) that is making use of a URL to display an image. document.images only seems to reference image tags. The collection needs to include background images, input type = image,...
2
3092
by: Jonny B | last post by:
Hi all, I'm working on an a clientside xslt using jscript that passes a parameter to the xsl. I've got it working no problem in IE but cant get it to work in Mozilla. Can anyone help? This is my IE code - <html> <head> <title>CEL Learning</title>
1
3771
by: aashishn86 | last post by:
i create dynamic rows using this function : function addRow() { var tbl = document.getElementById('applications'); var lastRow = tbl.rows.length; var iteration = lastRow; var row = tbl.insertRow(lastRow);
0
7432
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7689
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7943
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7786
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5359
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5076
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3490
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3470
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
743
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.