IP 2003 Java-script: How to add HTML tags to Rich Text box - InfoPath Dev
in

InfoPath Dev

IP 2003 Java-script: How to add HTML tags to Rich Text box

Last post 05-08-2009 02:00 PM by aesalazar. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 05-07-2009 05:36 PM

    IP 2003 Java-script: How to add HTML tags to Rich Text box

    Hi guys.  I am kind of stuck here.  I want to be able to work with the contents of an IP Rich Text box and add formatted content (bold, underline, carriage returns, etc.).  I assume I will have to add the HTML tags some how but I havent had much luck doing it.  Doing a straight .selectSingleNode.text = "xxx" only results in the HTML code showing up as plain text.  I tried replacing the .xml content of the node but get an error saying the the wrong number of parameters were passed.

     I have turned up how-to's when doing it in .net but nothing from within IP itself using plain old javascript.

     Thanks for any help

     Ernie

    Filed under: ,
  • 05-08-2009 02:00 PM In reply to

    Re: IP 2003 Java-script: How to add HTML tags to Rich Text box

    Havent figure this out yet but figure what I would post what I have so that others might get at least a little benefit.

    It seems that a rich text box is a collection of HTML tags broken out in separate nodes within the namespace of the rich text box.   I have been able to clone HTML tags and text that are ALREADY in the rich text box by doing something like this:

         pn = XDocument.DOM.selectSingleNode("//dfs:myFields/my:Reporting/my:Summary_Methods")

         pn.appendNode(pn.childNodes[0].cloneNode(true))

    In this case, childnode 0 might be something like a bolded word followed by plain text that I typed manually in the IP form.  Problem is I can copy a node but can only change its text and not the HTML tags that surround it.  I was able to create a node from scratch with this:

        xNode= XDocument.DOM.createNode(1, "strong","http://www.w3.org/1999/xhtm");
        xNode.text = "X"

     which ended up being a bolded "X" according to:

       xNode.xml: "<strong xmlns="http://www.w3.org/1999/xhtm">X</strong>"

    Great, I thought I had it until I realized I canNOT do an appendChild to stick xNode in pn as a child.  It gives me an error saying that it is not in the expect format.  Basically xNode is setting in limbo not really assigned to anything in the tree.

    So does anyone know of a way to use the createNode method at the node where I need to add xNode?  I cant simply do:

        xNode = XDocument.DOM.selectSingleNode("//dfs:myFields/my:Reporting/my:Summary_Methods") .createNode(1, "strong","http://www.w3.org/1999/xhtm");

    since the method is not support at that level.

     I am about ready to give up but if anyone else knows of a way, please let me know.  I cant believe it is this hard.

    Thanks

    Ernie

     

Page 1 of 1 (2 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.