![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I have searched much but cannot find answer to this seemingly simple question. I have a function that builds an html element like this, which works fine: document.getElementById("message").innerHTML += "<br>" + (i + 1) + ": <a href='javascript lace("+ p[1] + "," + p[0] + ")'>" + result.Placemark[i].address + "</ a>"; I have changed it to this: document.getElementById("message").innerHTML += "<br>" + (i + 1) + ": <a href='javascript lace("+ p[1] + "," + p[0] + ",'" + o.id + "','" + result.Placemark[i].address + "')'>" + result.Placemark[i].address + "</ a>"; There is a single quote on either side of o.id and result..., if you cannot tell ", ' ". But this single quote never gets built. I have tried \, escape(), String.charFromCode(39) with eval, and other things. It just breaks the href up and what gets generated is: a href="javascript lace(42.415392,-71.110948,"ctl00_contentplaceholder1_formview1_mytextbox="" ,="" 127="" main="" st,="" medford,="" ma="" 02155,="" usa="" )="" and this translates to: javascript lace(42.415392,-71.110948, Why is it dropping after thecomma? It should be: javascript lace(42.415392,-71.110948,'ctl00_contentplaceholder1_formview1_myt extbox','127main st, medford, ma') It is turnning the o.id and result.Placemark[i].address in to variables, and I cannot figure out why. I want to pass them as strings to another function. I am using Firefox 3. Thank you for any help. |
lace("
#3
| |||
| |||
|
|
On Jul 1, 4:04 pm, jmDesktop <needin4mat... (AT) gmail (DOT) com> wrote: I have searched much but cannot find answer to this seemingly simple question. *I have a function that builds an html element like this, which works fine: * * * * * * * * * * * * * document.getElementById("message").innerHTML += * * * * * * * * * * * * * "<br>" + (i + 1) + ": <a href='javascript lace("* * * * * * * * * * * * * + p[1] + "," + p[0] + * * * * * * * * * * * * * ")'>" + result.Placemark[i].address + "</ a>"; I have changed it to this: * * * * * * * * * * * * * document.getElementById("message").innerHTML += * * * * * * * * * * * * * "<br>" + (i + 1) + ": <a href='javascript lace("* * * * * * * * * * * * * + p[1] + "," + p[0] + ",'" + o.id + "','" + * * * * * * * * * * * * * result.Placemark[i].address + * * * * * * * * * * * * * "')'>" + result.Placemark[i].address + "</ a>"; There is a single quote on either side of o.id and result..., if you cannot tell ", ' ". *But this single quote never gets built. *I have tried \, escape(), String.charFromCode(39) with eval, and other things. *It just breaks the href up and what gets generated is: a href="javascript lace(42.415392,-71.110948,"ctl00_contentplaceholder1_formview1_mytextbox="" ,="" 127="" main="" st,="" medford,="" ma="" 02155,="" usa="" )="" and this translates to: * javascript lace(42.415392,-71.110948, *Why is it dropping after thecomma? It should be: javascript lace(42.415392,-71.110948,'ctl00_contentplaceholder1_formview1_*my textbox','127main st, medford, ma') It is turnning the o.id and result.Placemark[i].address in to variables, and I cannot figure out why. *I want to pass them as strings to another function. I am using Firefox 3. *Thank you for any help. Most likely problem is to do with your "<a href='javascript lace("Note the opening single quote in href, so when the browser encounters next single quote it considers it to be end of href string. You will have to escape those, or (I think this is more likely to work) use double quotes to encapsulate your strings...- Hide quoted text - - Show quoted text - |
#4
| |||
| |||
|
|
On Jul 1, 11:16 am, GArlington <garling... (AT) tiscali (DOT) co.uk> wrote: On Jul 1, 4:04 pm, jmDesktop <needin4mat... (AT) gmail (DOT) com> wrote: and this translates to: javascript lace(42.415392,-71.110948, Why is it dropping after thecomma? It should be: javascript lace(42.415392,-71.110948,'ctl00_contentplaceholder1_formview1_Â*m ytextbox','127main st, medford, ma') It is turnning the o.id and result.Placemark[i].address in to variables, and I cannot figure out why. I want to pass them as strings to another function. I am using Firefox 3. Thank you for any help. Most likely problem is to do with your "<a href='javascript lace("Note the opening single quote in href, so when the browser encounters next single quote it considers it to be end of href string. You will have to escape those, or (I think this is more likely to work) use double quotes to encapsulate your strings... I knew as soon as I posted I'd figure it out. I just use double quotes. "\"". I didn't know you could use double quotes. I thought that javascript would only take single quotes. I tried it and it worked. |
![]() |
| Thread Tools | |
| Display Modes | |
| |