tony danza
tony danza

Reputation: 306

double quotes use in javascript

I'm adding an hidden input as something in a select is choosen, using the onchange event with some jsp vars. I add some text to the div I'm working on but there are too many quotes and double quotes so I don't understand how to do it. Does anyone have any idea?

<select name="opt_name%>" onchange="$('#dati_opzioni').append('<input type="hidden" name="optdesc_'+<%=opt.getCdOpzione()%>+'" value="'+<%=optLabel%>+'_'+this.options[this.selectedIndex].text+'"/>');">

Upvotes: 0

Views: 349

Answers (2)

Ani
Ani

Reputation: 4523

try this:

<select name="<%=opt_name%>" onchange="$('#dati_opzioni').append('<input type=""hidden"" name=""optdesc_'+<%=opt.getCdOpzione()%>+'"" value=""'+<%=optLabel%>+'_'+this.options[this.selectedIndex].text+'""/>');">

Upvotes: 0

Packet Tracer
Packet Tracer

Reputation: 3924

Try using html entities for double quotes (as & quot; without blanks) inside the onchange="..."

<select name="opt_name%>" onchange="$('#dati_opzioni').append('<input type=&quot;hidden&quot; name=&quot;optdesc_'+<%=opt.getCdOpzione()%>+'&quot; value=&quot;'+<%=optLabel%>+'_'+this.options[this.selectedIndex].text+'&quot;/>');">

Upvotes: 1

Related Questions