Reputation: 25389
I'm trying to combine these variables and append them to a select tag but the vars contain special characters and everything gets all jumbled up. No matter how I try to escape the special characters I can't get it to work. Can anyone take a look and tell me what I'm doing wrong?
var contractid = $(this).attr("ows_ID");
var hrefa = "javascript\:SelectField\(\'\{808AEFE9-F68B-4F7B-AF62-C5B32723BBC1\}\'\,\'";
var hrefb = "'\)\;return\ false\;";
var optionline = "<option value='"+hrefa+""+contractid+""+hrefb+"'>otherstuff</option>";
The final product is supposed to look like this:
javascript:SelectField('{808AEFE9-F68B-4F7B-AF62-C5B32723BBC1}','133');return false;
but it always comes out like this:
false;'="" {808aefe9-f68b-4f7b-af62-c5b32723bbc1}','115');return="" value="javascript:SelectField("
Upvotes: 1
Views: 603
Reputation: 14863
I've played around on jsfiddle now.
This looks correct to me?
Upvotes: 1
Reputation: 77107
You're making it more complex than it needs to be. Just reverse the quotes in the output.
var contractid = $(this).attr("ows_ID"),
hrefa = "javascript:SelectField('{808AEFE9-F68B-4F7B-AF62-C5B32723BBC1}','",
hrefb = "');return false;",
optionline = '<option value="' + hrefa + contractid + hrefb + '">otherstuff</option>';
Upvotes: 1