html - String with whitespace in javascript -


i have string "magic word". need use value in html checkbox generated javascript.

in javascript

var itemvalue= "magic task"; var opt = "<input type='checkbox' name='test' id='test' value="+ itemvalue+ "/>"+itemvalue+ "<br />"; alert(opt);  $(optiondiv).append(opt); 

in alert displaying actual value after submitting form getting first word value.it ignoring second word.

thanks ravi kant

you need wrap value single quotes:

"<input type='checkbox' name='test' id='test' value='" + itemvalue + "' />" 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

java - Using an Integer ArrayList in Android -