Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #31819
| Path | csiph.com!feeder.erje.net!2.eu.feeder.erje.net!border1.nntp.ams1.giganews.com!nntp.giganews.com!peer03.ams1!peer.ams1.xlned.com!news.xlned.com!peer03.am4!peer.am4.highwinds-media.com!peer02.fr7!futter-mich.highwinds-media.com!news.highwinds-media.com!fx08.am4.POSTED!not-for-mail |
|---|---|
| From | <cyber@example.com> |
| Subject | Re: How to deal with "messy" quotes? |
| Newsgroups | comp.lang.javascript |
| References | <e02b3e17-0584-4751-ac26-28897820e1c2@googlegroups.com> <zuB3A.371253$kM7.70526@fx44.am4> <da86b656-3c71-4d67-bb56-26661b51ab61@googlegroups.com> |
| Lines | 65 |
| Message-ID | <VOB3A.181572$eh.139780@fx08.am4> (permalink) |
| X-Complaints-To | abuse@xsusenet.com |
| NNTP-Posting-Date | Mon, 12 Dec 2016 18:15:17 UTC |
| Organization | free.xsusenet.com |
| Date | Mon, 12 Dec 2016 18:15:17 GMT |
| X-Received-Bytes | 2568 |
| X-Received-Body-CRC | 3695199330 |
| X-Original-Bytes | 2620 |
| Xref | csiph.com comp.lang.javascript:31819 |
Show key headers only | View raw
justaguy <lichunshen84@gmail.com> wrote:
> On Monday, December 12, 2016 at 12:53:40 PM UTC-5, cy...@example.com wrote:
>> justaguy <> wrote:
>> >
>> > HTML:
>> > <html>
>> > <body>
>> > <span id="nav"></span>
>> > </body>
>> > </html>
>> >
>> > JavaScript:
>> > <script>
>> >
>> > var s = document.getElementById('nav'),
>> > num = 0,
>> > fn = " a new field name ";
>> > /* in my actual code, the var s represent an element dynamically created
>> > but to get key point across I'm using static element here
>> > */
>> > s.innerHTML = " " + fn + " <input type='button' value='x' onclick = 'newFN("+fn+" + "," +num+);'>";
>> >
>> > var newFN = function(f,n) {
>> > console.log(f,n);
>> > }
>> >
>> > </script>
>> >
>> > Intention:
>> > for the s.innerHTML to have a button, with a "+" value/sign, upon click of which, it loads a function named "newFN" with two parameters
>> >
>> > Problem:
>> > Not sure to how to manage the quotes (both singles and doubles) for the s.innerHTML line, the right side of the equation.
>> >
>> > Thanks.
>>
>> This should work:
>>
>> <html>
>> <body>
>> <span id="nav"></span>
>> <script>
>>
>> var s = document.getElementById('nav'),
>> num = 0,
>> fn = " a new field name ";
>> /* in my actual code, the var s represent an element dynamically created
>> but to get key point across I'm using static element here
>> */
>> s.innerHTML = " " + fn + " <input type='button' value='x' onclick = 'newFN(\""+fn+" + \", \"+num+\");'>";
>>
>> var newFN = function(f,n) {
>> console.log(f,n);
>> }
>>
>> </script>
>>
>> </body>
>> </html>
>
> Getting close except that the num var value has not been passed down. And since it's a number we don't need quotes for it as a parameter value. Thanks.
>
This should pass the num variable:
s.innerHTML = " " + fn + " <input type='button' value='x' onclick = 'newFN(\""+fn+" + \", "+num+");'>";
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
How to deal with "messy" quotes? justaguy <lichunshen84@gmail.com> - 2016-12-11 16:23 -0800
Re: How to deal with "messy" quotes? JJ <jj4public@vfemail.net> - 2016-12-12 12:42 +0700
Re: How to deal with "messy" quotes? justaguy <lichunshen84@gmail.com> - 2016-12-12 09:56 -0800
Re: How to deal with "messy" quotes? JJ <jj4public@vfemail.net> - 2016-12-13 18:18 +0700
Re: How to deal with "messy" quotes? JJ <jj4public@vfemail.net> - 2016-12-13 18:22 +0700
Re: How to deal with "messy" quotes? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-12-13 13:10 +0100
Re: How to deal with "messy" quotes? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-12-12 20:43 +0100
Re: How to deal with "messy" quotes? <cyber@example.com> - 2016-12-12 17:53 +0000
Re: How to deal with "messy" quotes? justaguy <lichunshen84@gmail.com> - 2016-12-12 10:05 -0800
Re: How to deal with "messy" quotes? <cyber@example.com> - 2016-12-12 18:15 +0000
Re: How to deal with "messy" quotes? justaguy <lichunshen84@gmail.com> - 2016-12-12 14:10 -0800
Re: How to deal with "messy" quotes? justaguy <lichunshen84@gmail.com> - 2016-12-12 16:56 -0800
Re: How to deal with "messy" quotes? <cyber@example.com> - 2016-12-13 11:49 +0000
Re: How to deal with "messy" quotes? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-12-13 13:17 +0100
Re: How to deal with "messy" quotes? <cyber@example.com> - 2016-12-13 18:32 +0000
Re: How to deal with "messy" quotes? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-12-13 19:47 +0100
Re: How to deal with "messy" quotes? <cyber@example.com> - 2016-12-13 19:43 +0000
Re: How to deal with "messy" quotes? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-12-14 12:24 +0100
Re: How to deal with "messy" quotes? justaguy <lichunshen84@gmail.com> - 2016-12-13 17:07 -0800
Re: How to deal with "messy" quotes? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-12-12 21:19 +0100
Re: How to deal with "messy" quotes? justaguy <lichunshen84@gmail.com> - 2016-12-12 12:51 -0800
Re: How to deal with "messy" quotes? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-12-12 20:50 +0100
csiph-web