JS -- XML Question - Can I add attributes using Javascript?

I want to add an attribute to an element tag, but I don't see how to do it programmatically. Is it possible? Also, is there a way to name an element tag dynamically? For example:
The way to add a child element is to either use the appendChild method like this:
XMLObject.appendChild(<childElement/>);
XMLObject.childElement= "something";
or just add it like this:
XMLObject.childElement = "something";
Right? (Side Question: Is there a difference between these two methods?).
What I want to do is to either add a dynamic attribute to a statically named child, or to create a dynamically named child.
I haven't been able to figure this out myself. Any ideas?

Maybe have a look at Mozilla's E4X tutorial: https://developer.mozilla.org/en/E4X_Tutorial/
There's no need for eval() here. (There usually isn't.) Use:
XMLObject.appendChild(<{nameReference}/>);
To add an attribute, you can just use:
XMLObject.@new_att = "the value";
Jeff

Similar Messages

  • Is there a way that you can have two different text fields (email, phone) that one at least one of them must be completed before submitting the form? Can it be done using javascript in the validation tab? if so, how?

    Is there a way that you can have two different text fields (email, phone) that one at least one of them must be completed before submitting the form? Can it be done using javascript in the validation tab? if so, how?

    Here is one solution:
    // mouse up action for submit button;
    function GetField(cName) {
    // get field object for cName field with error checking;
    var oField = this.getField(cName);
    if(oField == null) app.alert("Error accessing field named " + cName + "\nPleae verigy field name, spelling and capitalizeation.", 1, 0);
    return oField;
    } // end GetField function;
    var oPhone = GetField("phone");
    oPhone.required = oPhone.value == oPhone.defaultValue;
    var oEmail = GetField("email");
    oEmail.required = oEmail.value == oEmail.defaultValue;
    if(oPhone.required && oEmail.required) {
    app.alert("Missing required fields.", 1, 0);
    } else {
    app.alert("Submitting form", 3, 0);
    // additional code for submission;

  • Please clarify: can you add attributes to the Out of Box classes?

    In this thread,
    http://technet.oracle.com:89/ubb/Forum36/HTML/000116.html
    It said, (March 21, 2001)
    "You are not allowed to add attributes to the Out of Box classes that ship with IFS. You have to subclass the out-of-box attributes and define your custom attributes as extended attributes of your subclass. The add button is only active when the class you are viewing is not one of the out of box classes"
    In the 1.9 documentation on page 179 I see
    "Oracle 9iFS also allows you to add or modify attributes on content types after they
    have been created.
    Or, you may need to add custom attributes to the Document and Folder content types that come with Oracle 9iFS. You can add
    attributes to a content type at any time"
    Is this a new feature of 1.9?
    Would a good workaround be to create a PropertyBundle for each Document and Folder? Would there be a big performance hit?
    I dont want to create a new folder type and a new document type since I'm not sure how the rest of the system will use them.
    Someone please respond, I've been trying to figure this out all day.
    Thanks in advance
    Mitch
    null

    In the isshell in ifs 1.1.9, I do a
    ls -attrall
    and I see "null" next to the property bundle. I assume this to mean that no property bundle has been created for this folder instance.
    As for categories, 1.2 doc states.. "A folder, ... can be associated with zero,one or more categorys" I will have to create a new category for each file and or folder.
    I really want to have additional attributes for each file.
    I dont want to subclass folder because, if a user does a drag and drop in NTFS a folder will be created and not a MyFolder.
    I have a kludge for now; I put a comma delimited list of items in description field.
    Apparently this limitiation, is changed in 1.2. See above.
    Thanks for your help. IFS is a really great product. Cant wait for 1.2 on NT.
    Mitch
    null

  • Can't add row using table sorter

    I had a jtable with my own mytableModel that implements AbstractTableModel. In mytableModel, I have addRow, removeRow... so I can delete/add row dynamically by calling mytableModel.addRow(..). Everything works fine.
    However, after I added the table sorter and table map (got the code from the tutorial).
    MyTableModel myModel = new MyTableModel();
    TableSorter sorter = new TableSorter(myModel);
    JTable table = new JTable(sorter);
    sorter.addMouseListenerToHeaderInTable(table);
    Now, when i call mytableModel.addRow(..), it doesn't work anymore. It doesn't add a row anymore, why?
    Thank you so much for your help.

    I don't have a addRow method in TableSorter. My addRow method is in myTableModel. So, when I need to addRow, I called myTableModel.addRow, In my addRow method, I have fireTableRowsInserted method. This used to work using integrating with TableSorter.
    Do I need to move all my addRow, addCol....DelRow... to TableSorter? The table data are stored in myTableModel. I guess I really doesn't know how the TableSorter work :(
    Thanks

  • Quick Question - Can I add this AMD Phenom X4 9950 to my motherboard

    Hi
    Can I add this processor ( http://www.ebuyer.com/product/150466 ) to my new rig below ?
    Oh and what cooling fan should I get ( http://www.ebuyer.com/store/Components/cat/Cooling-Fans ) incase I want to overclock ?
    Thanks

    Quote from: Henry on 14-December-08, 10:32:29
    Have a look for yourself, no Phenom/quads listed >> K9N Neo V3 CPUs <<
     Edit: Best you can do is 89W X2 6000+
    Ok cool - I take it this is ok then: http://www.ebuyer.com/product/149211  ??
    Still stuck on what cooler to get for it ( http://www.ebuyer.com/store/Components/cat/Cooling-Fans ) for overclocking ?
    [I'm saving up for i7 but needed a wee boost in the mean time]

  • Can't submit JSF using Javascript

    I apologize if this is an obvious newbie question.
    I have a simple JSF page with a component users can click on to select a number. Using Javascript, I populate a textbox with the number they select, then attempt to submit the form, also using Javascript. But this doesn't work.
    The form submits and returns as though the user had submitted without a value in the textbox, and then their number appears in the textbox (it should be empty at this point).
    The form works fine if I use Javascript only to set the value in the textbox and require the user to manually press the Submit button.
    TIA for any help!

    Sorry, this is in the wrong place (and I can't find a way to delete it). Please ignore.

  • Import an xml file into adobe designer field using javascript

    Adobe javascript experts ,please help me.
    I need to load the data from an xml file into a text field in designer
    using javascript and then go through each node in the loaded xml and compare that with form fields in designer and if matching fill the value(node's value from the loaded xml) in form fields.
    Please give ur suggestions.
    Thanks in advance!!!
    regards,
    sowmya

    Thanks for the fast response.
    I saw your example and specifically the javascript code
    xfa.host.importData("filename.xml").
    Just by giving this alone how do I access the values in the xml???
    Just by giving the above javascript, my value is not getting populated when I see in pdf preview.
    But apart from that you have done dataconnection also and binding in all the columns.What is this for??
    Could you kindly explain what u r doing step by step??
    Thanks again.
    regards,
    Sowmya

  • How can I call actionListener using JavaScript

    Dear Programmers
    I have to use javascript in order to call a specific actionListener when a window is close. Therefor I inserted the following code to the jsp:
    <script type="text/javascript">
    window.onunload = function(){......};
    </script>
    But how can call a specific actionListener? I saw that I can use submit(), but this method doesn't perform any actionListener. I didn't find where the actionListener is specified after doing "view source" on the browser.
    Please help me

    Hello,
    I think you can do this:
    <h:form id="formId">
    <h:commandButton id="buttonId" actionListener="..." />
    Then you can call:
    document.forms.formId['formId:buttonId'].click();
    to invoke the action listener. If you don't want to display the commandButton on screen, you may apply a css style to hide it.
    Billy

  • How to populate the xml file into treeview including attributes using dom method in c# windows from???

    <?xml version="1.0" standalone="yes"?>
    <Student_Details>
    <Student Id="1">
    <Name>sandeep</Name>
    <Age>12</Age>
    <Mobile>123456789</Mobile>
    </Student>
    <Student Id="2">
    <Name>ololjk</Name>
    <Age>kjlokmo</Age>
    <Mobile>njonojniohuj</Mobile>
    </Student>
    <hello Id="10">
    </hello>
    <Student Id="3">
    <Name>Sandeep Pr</Name>
    <Age>12</Age>
    <Mobile>9865231870</Mobile>
    </Student>
    <Student Id="4">
    <Name>ololjk</Name>
    <Age>kjlokmo</Age>
    <Mobile>njonojniohuj</Mobile>
    </Student>
    all i can fount in internet is which will not display the attributes so pls upload a proper code which also creates an attribute node???
    Sandeep Puvvadi

    Enumerate your XML using
    XDocument. For each element
    Generate a new TreeNode with whatever text you want to show
    Insert the node into your tree
    Enumerate all the attributes of the element using the
    Attributes() method
    Insert a child node of the element node for each attribute with whatever text you want to show
    Note that your XML is not valid.  You have a <hello> element in the middle of it and the root element is not closed. You'll need to fix that before the XML can be parsed.
    Michael Taylor
    http://blogs.msmvps.com/p3net

  • Question - Can FCP 5 be used on more than 1 mac??

    hello
    I have a macbook pro and i currently have final cut pro 5. I'm planning on buying another macbook pro and i would like to add FCP 5 to it, is it possible to have the same program on more than 1 mac, without it disabling my use on the previous macbook pro?
    also i will be updating one of my macbook pro from tiger to snow leopard, does anyone know if FCP 5 will work with the new snow leopard ??
    Thank You
    Happy Holidays

    Intel Mac? sorry what does that mean??
    All Macs made in 2006 and later use an Intel processor. Earlier models used IBM Power PC processors.
    and you said - Snow Leopard will NOT work with FCP 5? what if i get the update for fcp 5? the update that works with the avchd files?
    You need at least Final Cut Studio 1.1 which includes FCP 5.1. That version is no longer sold by Apple. While you might find it on ebay or similar, you can upgrade to Final Cut Studio 3 for $299.

  • I have NDS 4.16, and I have iMS 5.1 running on Sun, Solaris 8. I want to know how can I add users using the command line instead of the console. My problem is how to set the password to this user?

     

    You can use ldapmodify found in <ServerRoot>/shared/bin
    for example
    ./ldapmodify -h ldaphost -D "cn=directory manager" -w password -f <name of LDIF file>
    Here's an example LDIF file
    dn: uid=cms,ou=people,o=balius.com,o=Universe
    changetype: add
    objectClass: person
    objectClass: organizationalPerson
    objectClass: inetOrgPerson
    objectClass: inetUser
    objectClass: ipUser
    objectClass: inetMailUser
    objectClass: inetLocalMailRecipient
    objectClass: nsManagedPerson
    objectClass: userPresenceProfile
    cn: Chad M. Stewart
    sn: Stewart
    initials: CMS
    givenName: Chad
    pabURI: ldap://host:389/ou=cms,ou=people,o=balius.com,o=Universe,o=pab
    mail: [email protected]
    mailDeliveryOption: mailbox
    mailHost: my.mailhost.com
    uid: cms
    dataSource: Chad by hand
    userPassword: users-password-here
    inetUserStatus: active
    mailUserStatus: active
    mailQuota: -1
    on a subsequent search you'd see something like
    userpassword: {SHA}S3e+L/K6

  • Can you add annotations using an AcroAVDoc when opened using OpenInWindowEx?

    I am writing a C# application in which users will need to annotate documents. I would prefer to use Acrobat's standard annotation tools (and toolbar). I am currently using the command OpenInWindowEx(filename, handle, AVOpenParams.AV_EXTERNAL_VIEW, ...) (of an AcroAVDoc object) to open a PDF in a window that my application can control. Unfortunately I cannot seem to get the annotation tools to display. In fact, the whole thing appears to be read only (with the exception of e-sigs). When using just the Open command of an AcroAVDoc the file opens in Acrobat and behaves as expected, but then I cannot resize the window or move it with the other windows of the application.
    Thanks for reading,
    -Dump987

    All,
    I moved the project from .NET 3 to .NET 4 to take advantage of dynamic objects, and hoped to be able to use the same type of syntax as one can use in VB.NET to work with the JSObject. Unfortunately, no matter what I try, I get the exception "Value does not fall within the expected range." Can anyone advise on whether we can use dynamic objects?
    Example:
    AcroPDDoc pddoc = new AcroPDDoc();
    pddoc.Open("C:\\test.pdf");
    dynamic jso = pddoc.GetJSObject();
    jso.Collab.showAnnotToolsWhenNoCollab = true; // or jso.console.Show(); it doesn't matter anything seems to throw the exception
    Thanks,
    -Dump987

  • Stupid question: can't add classes to .nib in IB

    I only looked at XCode many years ago, and then only briefly, so I'm probably missing something really obvious :}
    When I've created a new class in XCode, and drag the .h file to the .nib window in IB, it refuses to add it. It does show the little green + showing that it's intending to do it, but then it doesn't.
    This has been driving me nuts for the past hours, so any pointers will be appreciated very much!
    Alex

    If you are using Interface Builder 3.0, after you drag a header file into a .nib, there won't be feedback.
    But if you open the sixth tab of the inspector, the one with an info icon, under Class Identity is a drop-down list of available classes, you will find the custom class corresponding to the aforementioned header file in the list.
    -- Sherlock Asimov

  • Validate xml generates errors on template attributes using Expression Langu

    I'm getting errors like: "Error(0,0): Attribute linkText not defined on element myTemplate:smart_base".
    where linkText is an attribute defined in my template file smart_base.
    I'm using Jdev 10G and expression language.
    However, the code for both the uix and uit files work fine together. Does anyone know what I need to do to eliminate these errors?
    In the code below, the only attribute that gets no error is "selectedTab".
    Thanks, Steve
    My uix code is:
    <myTemplate:smart_base
    selectedTab="1"
    linkText="SMART - View Frameworks"
    helpPage="Framework.htm"
    studyText="${sessionScope.currentStudy.StudyName}"
    frameworkText="${sessionScope.currentStudy.FrameworkName}">
    My template code is:
    <templateDefinition xmlns="http://xmlns.oracle.com/uix/ui"
    xmlns:ui="http://xmlns.oracle.com/uix/ui"
    xmlns:data="http://xmlns.oracle.com/uix/ui"
    targetNamespace="http://www.example.org/demo/templates"
    expressionLanguage="el"
    localName="smart_base">
    <type base="ui:pageLayout">
    <attribute name="linkText" javaType="string" />
    <attribute name="selectedTab" javaType="int"/>
    <attribute name="helpPage" javaType="string"/>
    <attribute name="studyText" javaType="oracle.cabo.ui.data.DataObject"/>
    <attribute name="frameworkText" javaType="oracle.cabo.ui.data.DataObject"/>
    </type>

    Steven,
    If you restart JDeveloper and/or do File-->Close All after you are done editing the .uit file, do you still get the validation errors? The problem is probably that you edit the .uit file, and the code that does the validation in the UIX visual editor does not realize you changed your UIT file. This is a bug.
    - Ryan

  • If i have an ipad 3 with wifi feature only, can I add or use the data plan in another country?, if i have an ipad 3 with wifi feature only, can I add or use the data plan in another country?

    I have an ipad 3 with wifi feature only, can I use the data plan 3G in another country??

    No. You have no place for a sim card in the WiFi only iPad. You MAY be able to purchase a personal MIFI hotspot that will work with a data plan in another country. I have one here in the U.S. that I bought through Verizon, but I assume it will only work on the Verizon network here with my Verizon Data Plan. So you would need a data plan in the country in which you want to use the iPad if this option is available for you.

Maybe you are looking for

  • Installing ram into my macbook pro

    so i was wondering if i have the ability to upgrad my current ram from 4GB to 16GB (2x gb ram cards) i know certain models of the mac book pro simply wont function when upgraded, or atleast thats what ive seen personally. I know i could install it my

  • Text variable for 0calmonth in the rows possible ?

    Hello BW Experts, I have 0calmonth in the rows and restricted key figures in the column. Wondering if we can show the month description in the rows using text variable? Please let me know if that is possible and what are the steps.? Suggestions appre

  • Changing .include structure does not reflect in the original Table.

    Hi  Experts, I have a .include structure by name SDOKLO_INC referenced for table SRMTST07. As a part of unicode conversion, I have to Uncheck the Text Lang check box of Datalement SDOK_MSLAN. Hence I opened the structure of SDOKLO_INC and did the cha

  • ERROR: jbd can only store block numbers in 32 bits.

    I am running Oracle VM Server 2.2.1. When trying to format the following partition, an error is raised. [root@vmserver08 ~]# cat /proc/partitions major minor #blocks name 8 0 143247360 sda 8 1 104391 sda1 8 2 10482412 sda2 8 3 2096482 sda3 8 4 1 sda4

  • How to resend the bid

    Hi All, We have an item that we took off an existing PO because the vendor was not able to fulfill this part number. We removed (using trash can) this item off the PO so the item will go back into the sourcing cockpit. This item in now in the sourcin