473,322 Members | 1,620 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Escape sequence help Javascript innerHTML

Just the other day, I received help from this forum on escape sequences with some PHP code which would echo a Javascript onclick.

After the reply helped me, I asked him to explain why it worked and he gave me a URL explaining escape sequences. I thought I understood the tutorial, but I guess I do not.

The closest that I have come to making this work, is the following code:

Expand|Select|Wrap|Line Numbers
  1.  
  2.         myDiv.innerHTML += '<td><a href=\"javascript:myCastDetails(\''+(someNumberComing-1)+'\',\'document.getElementById(\'castname'+(someNumberComing-1)+'\').value\',\'document.getElementById(\'casttext'+(someNumberComing-1)+'\').value\',\'document.getElementById(\'castframecolor'+(someNumberComing-1)+'\').value\',\'document.getElementById(\'castpicture'+(someNumberComing-1)+'\').value\');\"><div>Previous</a></td><td align=right><a href="#">Next</a></div></td>';
  3.  
  4.  
From the preview, it appears as though there is gap between "some" and "NumberComing", but there isn't.

When you place your mouse over the link generated the output at the bottom of the browser is this:

Expand|Select|Wrap|Line Numbers
  1.  
  2. "myCastDetails('0','document.getElementById('castname0').value','getElementById('casttext0').value','getElementById('castframecolor0').value','getElementById('castpicture0').value');"
  3.  
  4.  
Once more, there appears to be a space between "cast" and "name" but there isn't -- apparently I cannot even post correctly :-(

I would like it to be this:

Expand|Select|Wrap|Line Numbers
  1.  
  2. "myCastDetails('0','document.getElementById("castname0").value','getElementById("casttext0").value','getElementById("castframecolor0").value','getElementById("castpicture0").value');"
  3.  
  4.  
  5.  
Any help would be appreciated and thanks in advance :-)
Jun 22 '07 #1
3 4119
acoder
16,027 Expert Mod 8TB
To avoid all this, just put the function call into another function (all the stuff in the href from "javascript:castDetails(...". Then just call that. Saves messing with escaped singe and double quotes.
Jun 22 '07 #2
To avoid all this, just put the function call into another function (all the stuff in the href from "javascript:castDetails(...". Then just call that. Saves messing with escaped singe and double quotes.

You were absolutely correct. All what I truly needed to pass was what number and within the function that I was calling, I had all the elements waiting for a number so as to choose the correct element, which had I created hidden fields in a step before sending the number.

Thank you for help.
Jun 26 '07 #3
acoder
16,027 Expert Mod 8TB
You're welcome. Glad you got it working.
Jun 27 '07 #4

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

Similar topics

8
by: Joe | last post by:
I'm using Python 2.4 on Windows XP SP2. I'm trying to receive a command line argument that is a newline (\n) Here is the command line to use sample.py "\n" Here is a sample.py script
5
by: KathyB | last post by:
Hi, not sure this is the right group, but hoping someone may have experienced this. I'm passing html text as a parameter to a javascript. When it has an apostrophe in it, of course it does parse...
7
by: N U | last post by:
How to program your own escape sequence using basic functions available in C?
7
by: teachtiro | last post by:
Hi, 'C' says \ is the escape character to be used when characters are to be interpreted in an uncommon sense, e.g. \t usage in printf(), but for printing % through printf(), i have read that %%...
4
by: Abraham Luna | last post by:
can anyone tell me why this string throws an error: strValues += "<tr><td><a href=\"\#\" onclick=\"javascript:" + strTextBox + ".value='" + drRDK.ToString().Replace("\\", "\\\\").Replace("'",...
12
by: Jeff S | last post by:
In a VB.NET code behind module, I build a string for a link that points to a JavaScript function. The two lines of code below show what is relevant. PopupLink = "javascript:PopUpWindow(" &...
1
by: chuck | last post by:
Hi, I have a php function creating links from a products mysql database. some of the descriptions have characters that I need to escape but whatever i do, javascript doesn't like them. for...
5
by: vlsidesign | last post by:
The printf function returns "warning: unknown escape sequence: \040" for a backslash-space combination. If the ascii decimal number for space is 32 and the backslash is 92, why this particular...
1
by: RK | last post by:
Perhaps I'm confused somwhere in my understanding, but I'm trying to deal with some escaped text from an XML file which includes html markup and it appears there are a couple of techniques for...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.