This is using Mirth Connect which uses E4x and js.
Basically I have a variable that I want to populate the XML with.
var memberid = "1234";
var fieldsxml = new XML(<fieldvaluelist></fieldvaluelist>);
fieldsxml.field += <fieldvalue templatefieldid="446" value=#memberid/> //memberID
But its giving an error on the 3rd line: (I also tried just memberid without quotes)
DETAILS: TypeError: Open quote is expected for attribute "value"
associated with an element type "fieldvalue".
It works if the third line is this:
fieldsxml.field += <fieldvalue templatefieldid="446" value="memberid"/>
But that just adds the literal string "memberid" . I actually want value="1234" instead.
How can I do this?
Edit: The final XML should look like this.
<fieldvaluelist><fieldvalue templatefieldid="446" value="1234"/></fieldvaluelist>
You're almost there. Instead of using #memberId, use {memberId}:
fieldsxml.field += <fieldvalue templatefieldid="446" value={memberid}/>;
Related
I have a (simple, I guess) problem with quotes, single quotes, double quotes.
I have a JS that sends data to a php file, which responds sending some data back with json. In the code below, row.Dispon is part of the response (and is working OK). But I want to "echo" row.Element inside getElementById with no success. I've tried "+row.Element+", or "'+row.Element+'". What I'm doing wrong?
if (row.Dispon=="ImageReload") {
var text='Image changed';
document.getElementById(+row.Element+).value="due";
}
Considering your code snippet only, this should do the job for that specific problem:
if (row.Dispon == "ImageReload") {
var text = 'Image changed';
document.getElementById(row.Element).value = "due";
}
You would need quotes (or double quotes) and + operators if you were trying to build a string. See this example:
var id = 42;
document.getElementById('myId' + id).value = 'something';
Assuming that row.Element contains a string already, you can directly pass it to getElementById().
Some advice here:
Read more about functions on MDN
Read more about Document.getElementById on MDN
Consider using Document.querySelector
Hi I am getting property form properties file using locale,the below is the code for that
<fmt:setBundle basename="/filename" var="mybundle" />
by using the below code i am accessing one property
<fmt:message key="ErrorMesg" bundle="${mybundle}" var="ErrorMsgInfo" />
Now i want to populate this error message in javascript by using the below code which is inside of javascript
var InfoErrorMsg = "<c:out value='${ErrorMsgInfo}'/>";
I am using InfoErrorMsg inside alert.Expected behaviour :Please select 'We have a radiobutton i am getting as :Please select `'We have a radiobuttonby looking this it's not able to display/process single quote. To overcome this i tried the following waysFirst
String result = (String)pageContext.getAttribute("ErrorMsgInfo");
result = result.replaceFirst("'","\\\\'");
pageContext.setAttribute("d2dFexExInfoErrorMsg1",result);
Second
var InfoErrorMsg = "<c:out value='${fn:escapeXml(ErrorMsgInfo}'/>";
Third inside javascript i replace ' with \'
InfoErrorMsg = d2dFexExInfoErrorMsg1.replace(/'/g, "\'");
and the below one also
InfoErrorMsg = d2dFexExInfoErrorMsg1.replace(/'/g, "\\\\'");
Can anybody please help me to solve this one
I am trying to implement server side code on client side. "trvddl1" is a ascx control which contains a dropdownlist "ddltree". It was easy on server side but I am facing difficulty using the same in javascript.
How do I write the following code in javascript?
((DropDownList)trvddl1.FindControl("ddltree")).SelectedValue;
I tried
var abc = document.getElementById('<%=trvddl1.ClientID%>').value;
and
var Region = document.getElementById('<%=trvddl1.FindControl("ddltree")%>').value;
but javascript returned error. Is there some other keyword I am missing ?
Check the HTML output (Browser-->View Source) and locate the control there, see what the ID of that control has, and put that one into the getElementById() function.
Example:
<input id='ddltree' .... />
Then use:
var abc = document.getElementById('ddltree').value;
Perhaps you can try something like that:
// find all controls that have an id that ends with ddltree
// starts with would be [id*=ddltree]
var abc = document.querySelectorAll("[id$=ddltree]");
if(abc.length > 0) {
// got it !
console.log(abc[0].value);
}
Please note that querySelectorAll is not supported in all browsers (even though - most). Here is a reference.
Hi I am developing Android application using Titanium.I want to change value of particular attributes of json object.I tried following code :
var row_jsonfeed = this.responseText;
var jsonfeed = eval('('+row_jsonfeed+')');
my jsonfeed object look like this :
{"feeds":
[
{"username":"abc","user":"abc","feed":{"description":"dss","id":660,"user_id":1}},
{"username":"bcd","user":"bcd","feed":{"description":"dddd","id":659,"user_id":1}}
]
}
I want to change username value so I tried like this:
jsonfeed.feeds[0].username = "xyz";
alert(jsonfeed.feeds[0].username);
But it's not working.It not giving me changed value of username.Any other alternative way to do this. Instead of eval I also tried JSON.parse but that also not working.So i need proper way to do this.Thank you in advance.
I think the problem is with your call to eval. You forgot to concatenate your parens:
eval('(' + row_jsonfeed + ')');
I have been banging my head on this for the better part of a day; I need to count the number of childNodes in a parent div. It basically is acting like a list and each childNode is a row I want to count. The html looks like:
div<#class="list ">
div<#id="list-item-01">
div<#id="list-item-02">
div<#id="list-item-03">
div<#id="list-item-04">
div<#id="list-item-05">
...
</div>
My primary approach has been to use the getEval() function in Selenium using some javascript.
examples that have failed:
String locator = "xpath=//div[contains(#class,'list')]";
String jscript = "var element = this.browserbot.findElement('"+locator+"');";
jscript += "element.childNodes.length;";
String locator = "xpath=//div[#class='list']";
String jscript = "var element = this.browserbot.findElement('"+locator+"');";
jscript += "element.childNodes.length;";
Now I know the element is there and my xpath is correct because I have tried using .isElementPresent and that returns true. So something is funky with Selenium and divs.
I also poked around with document.evaluate() as my javascript command but that proved equally fruitless.
Why not use getXPathCount? Something like
getXPathCount("//div[contains(#class, 'list ')]/div[contains(#class, 'list-item-')]")
should do the trick.
.Net documentation
Java documentation
So these divs are created dynamically .
So when you create this , you will be using a variable for iteration like $i , $i++.
after printing divs add that value of $i to a hidden field.
if there are 3 divs , $i=3 , putvalue of hidden=3
just get the value of that field using javascript.
Or
Try these
http://api.jquery.com/parent/
http://api.jquery.com/children/