Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #39822 > unrolled thread
| Started by | Daniele Ferrarese <daniele.seversrl@gmail.com> |
|---|---|
| First post | 2021-04-01 07:13 -0700 |
| Last post | 2021-04-05 23:54 -0700 |
| Articles | 11 — 4 participants |
Back to article view | Back to comp.lang.javascript
Problem with string concatenation Daniele Ferrarese <daniele.seversrl@gmail.com> - 2021-04-01 07:13 -0700
Re: Problem with string concatenation The Natural Philosopher <tnp@invalid.invalid> - 2021-04-01 16:17 +0100
Re: Problem with string concatenation Daniele Ferrarese <daniele.seversrl@gmail.com> - 2021-04-01 08:39 -0700
Re: Problem with string concatenation Daniele Ferrarese <daniele.seversrl@gmail.com> - 2021-04-02 00:37 -0700
Re: Problem with string concatenation JJ <jj4public@gmail.com> - 2021-04-01 22:19 +0700
Re: Problem with string concatenation Daniele Ferrarese <daniele.seversrl@gmail.com> - 2021-04-01 08:40 -0700
Re: Problem with string concatenation Jon Ribbens <jon+usenet@unequivocal.eu> - 2021-04-01 15:50 +0000
Re: Problem with string concatenation Daniele Ferrarese <daniele.seversrl@gmail.com> - 2021-04-01 23:55 -0700
Re: Problem with string concatenation Daniele Ferrarese <daniele.seversrl@gmail.com> - 2021-04-02 00:25 -0700
Re: Problem with string concatenation Jon Ribbens <jon+usenet@unequivocal.eu> - 2021-04-02 15:25 +0000
Re: Problem with string concatenation Daniele Ferrarese <daniele.seversrl@gmail.com> - 2021-04-05 23:54 -0700
| From | Daniele Ferrarese <daniele.seversrl@gmail.com> |
|---|---|
| Date | 2021-04-01 07:13 -0700 |
| Subject | Problem with string concatenation |
| Message-ID | <9f08800c-e939-4b8f-84b1-86bc871cce0dn@googlegroups.com> |
Hello I'm still here asking for your help as a beginner. i'm trying to concatenate arguments of a function with the following string, onclick="show_cart(<?php echo $variabili[4];?>","<?php echo $variabili[6];?>","<?php echo $variabili[7];?>","<?php echo $variabili[5];?>)" but i think there are concatenation errors maybe for double quotes or i don't know. Could anyone help me? Thanks. Rgds - Daniele Ferrarese
[toc] | [next] | [standalone]
| From | The Natural Philosopher <tnp@invalid.invalid> |
|---|---|
| Date | 2021-04-01 16:17 +0100 |
| Message-ID | <s44o5q$76n$1@dont-email.me> |
| In reply to | #39822 |
On 01/04/2021 15:13, Daniele Ferrarese wrote:
> Hello
> I'm still here asking for your help as a beginner.
>
> i'm trying to concatenate arguments of a function with the following string,
>
> onclick="show_cart(<?php echo $variabili[4];?>","<?php echo $variabili[6];?>","<?php echo $variabili[7];?>","<?php echo $variabili[5];?>)"
>
> but i think there are concatenation errors maybe for double quotes or i don't know.
> Could anyone help me? Thanks.
>
> Rgds - Daniele Ferrarese
>
You probably need - unless they are JavaScript declared variables - to
turn your php $varaibili[]'s into strings...
i.e.
args="'$variabili[4]'.,.'$variabili[6]'.,.'$variabili[7]'.'$variabili[5]'"
// so args = 'arg1','arg2', etc...
onclick = "show_cart (<?php echo $args ?>);"
remember JS only takes undeclared *numerical* args without inverted commas.
So this is ok
var one, two;
show_cart(one,two);
and so is
show_cart(1,2);
But you have to do this if one and two are not numbers or declared
show_cart('one', 'two');
In all cases looking at 'show source' in the browser will help see what
JavaScript is seeing and with luck your browser also supports a console,
debugger and error log that can trap JavaScript errors
--
Religion is regarded by the common people as true, by the wise as
foolish, and by the rulers as useful.
(Seneca the Younger, 65 AD)
[toc] | [prev] | [next] | [standalone]
| From | Daniele Ferrarese <daniele.seversrl@gmail.com> |
|---|---|
| Date | 2021-04-01 08:39 -0700 |
| Message-ID | <e0c1edff-ea11-4530-843b-4c0250167a6dn@googlegroups.com> |
| In reply to | #39825 |
Il giorno giovedì 1 aprile 2021 alle 17:17:23 UTC+2 The Natural Philosopher ha scritto:
> On 01/04/2021 15:13, Daniele Ferrarese wrote:
> > Hello
> > I'm still here asking for your help as a beginner.
> >
> > i'm trying to concatenate arguments of a function with the following string,
> >
> > onclick="show_cart(<?php echo $variabili[4];?>","<?php echo $variabili[6];?>","<?php echo $variabili[7];?>","<?php echo $variabili[5];?>)"
> >
> > but i think there are concatenation errors maybe for double quotes or i don't know.
> > Could anyone help me? Thanks.
> >
> > Rgds - Daniele Ferrarese
> >
> You probably need - unless they are JavaScript declared variables - to
> turn your php $varaibili[]'s into strings...
>
> i.e.
> args="'$variabili[4]'.,.'$variabili[6]'.,.'$variabili[7]'.'$variabili[5]'"
> // so args = 'arg1','arg2', etc...
>
> onclick = "show_cart (<?php echo $args ?>);"
>
>
> remember JS only takes undeclared *numerical* args without inverted commas.
>
> So this is ok
> var one, two;
> show_cart(one,two);
>
> and so is
> show_cart(1,2);
>
> But you have to do this if one and two are not numbers or declared
>
> show_cart('one', 'two');
>
> In all cases looking at 'show source' in the browser will help see what
> JavaScript is seeing and with luck your browser also supports a console,
> debugger and error log that can trap JavaScript errors
>
>
> --
> Religion is regarded by the common people as true, by the wise as
> foolish, and by the rulers as useful.
>
> (Seneca the Younger, 65 AD)
Thank you very much for your explanation. It's clear.
I'll check.
Bst rgds - Daniele Ferrarese
P.S. - Very interesting your footer sentences !!!
[toc] | [prev] | [next] | [standalone]
| From | Daniele Ferrarese <daniele.seversrl@gmail.com> |
|---|---|
| Date | 2021-04-02 00:37 -0700 |
| Message-ID | <dc81d7ff-a3f7-4117-a6cb-8c307fbeb95en@googlegroups.com> |
| In reply to | #39825 |
Il giorno giovedì 1 aprile 2021 alle 17:17:23 UTC+2 The Natural Philosopher ha scritto:
> On 01/04/2021 15:13, Daniele Ferrarese wrote:
> > Hello
> > I'm still here asking for your help as a beginner.
> >
> > i'm trying to concatenate arguments of a function with the following string,
> >
> > onclick="show_cart(<?php echo $variabili[4];?>","<?php echo $variabili[6];?>","<?php echo $variabili[7];?>","<?php echo $variabili[5];?>)"
> >
> > but i think there are concatenation errors maybe for double quotes or i don't know.
> > Could anyone help me? Thanks.
> >
> > Rgds - Daniele Ferrarese
> >
> You probably need - unless they are JavaScript declared variables - to
> turn your php $varaibili[]'s into strings...
>
> i.e.
> args="'$variabili[4]'.,.'$variabili[6]'.,.'$variabili[7]'.'$variabili[5]'"
> // so args = 'arg1','arg2', etc...
>
> onclick = "show_cart (<?php echo $args ?>);"
>
>
> remember JS only takes undeclared *numerical* args without inverted commas.
>
> So this is ok
> var one, two;
> show_cart(one,two);
>
> and so is
> show_cart(1,2);
>
> But you have to do this if one and two are not numbers or declared
>
> show_cart('one', 'two');
>
> In all cases looking at 'show source' in the browser will help see what
> JavaScript is seeing and with luck your browser also supports a console,
> debugger and error log that can trap JavaScript errors
>
>
> --
> Religion is regarded by the common people as true, by the wise as
> foolish, and by the rulers as useful.
>
> (Seneca the Younger, 65 AD)
Sorry but your solution is not running. Google Chrome debug is giving "Unexpected token ' , ' " error message.
Anyhow thank you for your help.
[toc] | [prev] | [next] | [standalone]
| From | JJ <jj4public@gmail.com> |
|---|---|
| Date | 2021-04-01 22:19 +0700 |
| Message-ID | <109crr1ef5gei$.1q0d1qdvbe4by$.dlg@40tude.net> |
| In reply to | #39822 |
On Thu, 1 Apr 2021 07:13:21 -0700 (PDT), Daniele Ferrarese wrote: > Hello > I'm still here asking for your help as a beginner. > > i'm trying to concatenate arguments of a function with the following string, > > onclick="show_cart(<?php echo $variabili[4];?>","<?php echo $variabili[6];?>","<?php echo $variabili[7];?>","<?php echo $variabili[5];?>)" > > but i think there are concatenation errors maybe for double quotes or i don't know. > Could anyone help me? Thanks. > > Rgds - Daniele Ferrarese You're PHP-echoing variable contents to be used as variable names in JavaScript.
[toc] | [prev] | [next] | [standalone]
| From | Daniele Ferrarese <daniele.seversrl@gmail.com> |
|---|---|
| Date | 2021-04-01 08:40 -0700 |
| Message-ID | <8220805d-c5a0-4619-a02e-a4c4985bf9c7n@googlegroups.com> |
| In reply to | #39826 |
Il giorno giovedì 1 aprile 2021 alle 17:19:39 UTC+2 JJ ha scritto: > On Thu, 1 Apr 2021 07:13:21 -0700 (PDT), Daniele Ferrarese wrote: > > Hello > > I'm still here asking for your help as a beginner. > > > > i'm trying to concatenate arguments of a function with the following string, > > > > onclick="show_cart(<?php echo $variabili[4];?>","<?php echo $variabili[6];?>","<?php echo $variabili[7];?>","<?php echo $variabili[5];?>)" > > > > but i think there are concatenation errors maybe for double quotes or i don't know. > > Could anyone help me? Thanks. > > > > Rgds - Daniele Ferrarese > You're PHP-echoing variable contents to be used as variable names in > JavaScript. Thanks for your explanation. Bst rgds - Daniele Ferrarese
[toc] | [prev] | [next] | [standalone]
| From | Jon Ribbens <jon+usenet@unequivocal.eu> |
|---|---|
| Date | 2021-04-01 15:50 +0000 |
| Message-ID | <slrns6bqv2.2fck.jon+usenet@raven.unequivocal.eu> |
| In reply to | #39822 |
On 2021-04-01, Daniele Ferrarese <daniele.seversrl@gmail.com> wrote:
> Hello
> I'm still here asking for your help as a beginner.
>
> i'm trying to concatenate arguments of a function with the following
> string,
>
> onclick="show_cart(<?php echo $variabili[4];?>","<?php echo $variabili[6];?>","<?php echo $variabili[7];?>","<?php echo $variabili[5];?>)"
>
> but i think there are concatenation errors maybe for double quotes or
> i don't know.
> Could anyone help me? Thanks.
You're not actually concatenating anything. Nor are you implementing the
necessary encodings. Assuming what you're trying to do is concatenate
those 'variabili' things, you'd want something like:
onclick='show_cart(<?php
echo json_encode(
$variabili[4] . $variabili[6] . $variabili[7] . $variabili[5],
JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS
);
?>)'
Now go and say 500 Hail Marys for making me think about PHP.
[toc] | [prev] | [next] | [standalone]
| From | Daniele Ferrarese <daniele.seversrl@gmail.com> |
|---|---|
| Date | 2021-04-01 23:55 -0700 |
| Message-ID | <e6dee327-5378-4492-be19-b19ec531a6fdn@googlegroups.com> |
| In reply to | #39829 |
Il giorno giovedì 1 aprile 2021 alle 17:51:05 UTC+2 Jon Ribbens ha scritto: > On 2021-04-01, Daniele Ferrarese <daniele....@gmail.com> wrote: > > Hello > > I'm still here asking for your help as a beginner. > > > > i'm trying to concatenate arguments of a function with the following > > string, > > > > onclick="show_cart(<?php echo $variabili[4];?>","<?php echo $variabili[6];?>","<?php echo $variabili[7];?>","<?php echo $variabili[5];?>)" > > > > but i think there are concatenation errors maybe for double quotes or > > i don't know. > > Could anyone help me? Thanks. > You're not actually concatenating anything. Nor are you implementing the > necessary encodings. Assuming what you're trying to do is concatenate > those 'variabili' things, you'd want something like: > > onclick='show_cart(<?php > echo json_encode( > $variabili[4] . $variabili[6] . $variabili[7] . $variabili[5], > JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS > ); > ?>)' > > Now go and say 500 Hail Marys for making me think about PHP. Hi Jon Thank you for your help. I didn't sleep a wink all night to recite the Hail Marys. Now I can fall asleep peacefully. Wish you a nice day. Daniele
[toc] | [prev] | [next] | [standalone]
| From | Daniele Ferrarese <daniele.seversrl@gmail.com> |
|---|---|
| Date | 2021-04-02 00:25 -0700 |
| Message-ID | <cc9d6a64-653f-48a9-af2e-17ef3e0f56c3n@googlegroups.com> |
| In reply to | #39829 |
Il giorno giovedì 1 aprile 2021 alle 17:51:05 UTC+2 Jon Ribbens ha scritto: > On 2021-04-01, Daniele Ferrarese <daniele....@gmail.com> wrote: > > Hello > > I'm still here asking for your help as a beginner. > > > > i'm trying to concatenate arguments of a function with the following > > string, > > > > onclick="show_cart(<?php echo $variabili[4];?>","<?php echo $variabili[6];?>","<?php echo $variabili[7];?>","<?php echo $variabili[5];?>)" > > > > but i think there are concatenation errors maybe for double quotes or > > i don't know. > > Could anyone help me? Thanks. > You're not actually concatenating anything. Nor are you implementing the > necessary encodings. Assuming what you're trying to do is concatenate > those 'variabili' things, you'd want something like: > > onclick='show_cart(<?php > echo json_encode( > $variabili[4] . $variabili[6] . $variabili[7] . $variabili[5], > JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS > ); > ?>)' > > Now go and say 500 Hail Marys for making me think about PHP. Sorry Jon but is not running. Google Chrome debug is giving "Unexpected end of input" error.
[toc] | [prev] | [next] | [standalone]
| From | Jon Ribbens <jon+usenet@unequivocal.eu> |
|---|---|
| Date | 2021-04-02 15:25 +0000 |
| Message-ID | <slrns6edrm.2fck.jon+usenet@raven.unequivocal.eu> |
| In reply to | #39839 |
On 2021-04-02, Daniele Ferrarese <daniele.seversrl@gmail.com> wrote: > Il giorno giovedì 1 aprile 2021 alle 17:51:05 UTC+2 Jon Ribbens ha scritto: >> You're not actually concatenating anything. Nor are you implementing the >> necessary encodings. Assuming what you're trying to do is concatenate >> those 'variabili' things, you'd want something like: >> >> onclick='show_cart(<?php >> echo json_encode( >> $variabili[4] . $variabili[6] . $variabili[7] . $variabili[5], >> JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS >> ); >> ?>)' >> >> Now go and say 500 Hail Marys for making me think about PHP. > > Sorry Jon but is not running. Google Chrome debug is giving > "Unexpected end of input" error. The code I posted certainly works - I tested it. If it's not working in the context of the rest of your code you'll need to provide more information, e.g. the 'view source' of your output page.
[toc] | [prev] | [next] | [standalone]
| From | Daniele Ferrarese <daniele.seversrl@gmail.com> |
|---|---|
| Date | 2021-04-05 23:54 -0700 |
| Message-ID | <728d7217-6aec-4c60-a6b3-df87acb3f3afn@googlegroups.com> |
| In reply to | #39843 |
Il giorno venerdì 2 aprile 2021 alle 17:25:48 UTC+2 Jon Ribbens ha scritto: > On 2021-04-02, Daniele Ferrarese <daniele....@gmail.com> wrote: > > Il giorno giovedì 1 aprile 2021 alle 17:51:05 UTC+2 Jon Ribbens ha scritto: > >> You're not actually concatenating anything. Nor are you implementing the > >> necessary encodings. Assuming what you're trying to do is concatenate > >> those 'variabili' things, you'd want something like: > >> > >> onclick='show_cart(<?php > >> echo json_encode( > >> $variabili[4] . $variabili[6] . $variabili[7] . $variabili[5], > >> JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS > >> ); > >> ?>)' > >> > >> Now go and say 500 Hail Marys for making me think about PHP. > > > > Sorry Jon but is not running. Google Chrome debug is giving > > "Unexpected end of input" error. > The code I posted certainly works - I tested it. If it's not working > in the context of the rest of your code you'll need to provide more > information, e.g. the 'view source' of your output page. Hi Jon I'm sure that your code is running and that mistake is in the rest of my code. For that reason I decided to modify the function by requiring just one "variabile". Now I solved my problem. Anyhow thank you very much for your suggestion. Have a nice day. Daniele
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.javascript
csiph-web