user979331
user979331

Reputation: 11861

jquery add backslash to string

I am creating a input text box using jquery:

<input type='text' name='" + key + "-" + taskArray[i] + "' id='" + key + "-" + taskArray[i] + "' class='vendorDropdown' value='" + value.baseOrSchedStartList[i] + "' />

when Anthony's Excavating & Grading it returns Anthony how do I get to display the full text, here is what it looks like in html:

<input type="text" name="ANC0002-Water &amp; Sewer Installed" id="ANC0002-Water &amp; Sewer Installed" class="vendorDropdown ui-autocomplete-input" value="Anthony" s="" excavating="" &="" grading'="" autocomplete="off">

Upvotes: 2

Views: 751

Answers (2)

WhiteLine
WhiteLine

Reputation: 1991

try this , use value=\""+mvalue+"\"

<input type='text' name='" + key + "-" + taskArray[i] + "' id='" + key + "-" + taskArray[i] + "' class='vendorDropdown' value=\"" + value.baseOrSchedStartList[i] +"\" />

in this way you can use special characters and spaces also

Upvotes: 1

Navneeth
Navneeth

Reputation: 988

replace single quote( ' ) with double quote( " ), it will solve your issue.

<input type="text" name="' + key + '-' + taskArray[i] + '" id="' + key + '-' + taskArray[i] + '" class="vendorDropdown" value="' + value.baseOrSchedStartList[i] + '" />

Upvotes: 1

Related Questions