retrieve clean text between <td></td>

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • js

    #1

    retrieve clean text between <td></td>

    I have a table rendered with XSLT. The first column has a radio
    button controls for user to make a selection for a particular row.
    All the values in the remaining columns are all concated with a &#xA0;
    (blank). I need to retieve the text in each cell of that row if the
    radio button on that row is clicked. Each <TD> has a numeric ID so
    that I can use it with document.getEle mentById().inne rText method. I
    use Javascript to assign some hidden fields with these innerText
    before the form is submitted. Upon submission, the form would contain
    those values along with %90?. How can I get rid of those HTML encoded
    string and get only the text that appear in the browser using
    javascript? I am using IE6. I also need to have it working in Opera
    and Netscape. Thanks.
  • Shawn Milo

    #2
    Re: retrieve clean text between &lt;td&gt;&l t;/td&gt;

    androidsun@yaho o.com (js) wrote in message news:<23869fd0. 0405202133.18e6 6cf0@posting.go ogle.com>...[color=blue]
    > I have a table rendered with XSLT. The first column has a radio
    > button controls for user to make a selection for a particular row.
    > All the values in the remaining columns are all concated with a &#xA0;
    > (blank). I need to retieve the text in each cell of that row if the
    > radio button on that row is clicked. Each <TD> has a numeric ID so
    > that I can use it with document.getEle mentById().inne rText method. I
    > use Javascript to assign some hidden fields with these innerText
    > before the form is submitted. Upon submission, the form would contain
    > those values along with %90?. How can I get rid of those HTML encoded
    > string and get only the text that appear in the browser using
    > javascript? I am using IE6. I also need to have it working in Opera
    > and Netscape. Thanks.[/color]

    Can you post examples of the string you have and how
    you'd like it to look afterwards? You can probably
    do this pretty simply with a regular expression.

    Shawn

    Comment

    • nospam

      #3
      Re: retrieve clean text between &lt;td&gt;&l t;/td&gt;

      Thanks for the reply. The following is the XSLT template that render the
      table content, and Javascript that manipulate the values of the hidden
      fields before submit. Thank you.

      function fillTechRefresh Form()
      {
      var taskid = document.getEle mentById('txtTa skId').value;
      if (taskid == "")
      {
      alert("Please select task id by clicking the radio button")
      return false;
      }
      else
      {
      with (document.forms[0])
      {
      txtTaskId.value = document.getEle mentById('td' + taskid.toString () +
      '1').innerText;
      txtLastName.val ue = document.getEle mentById('td' + taskid.toString ()
      + '9').innerText;
      txtFirstName.va lue = document.getEle mentById('td' +
      taskid.toString () + '10').innerText ;
      //cboUserName.val ue = document.getEle mentById('td' +
      taskid.toString () + '2').innerText;
      cboUserName.val ue = txtLastName.val ue + ", " + txtFirstName.va lue;
      cboSerial.value = document.getEle mentById('td' + taskid.toString () +
      '3').innerText;
      txtScheduled.va lue = document.getEle mentById('td' +
      taskid.toString () + '4').innerText;
      txtReady.value = document.getEle mentById('td' + taskid.toString () +
      '5').innerText;
      txtDeployed.val ue = document.getEle mentById('td' + taskid.toString ()
      + '6').innerText;
      txtNewSystem.va lue = document.getEle mentById('td' +
      taskid.toString () + '7').innerText;
      txtComments.val ue = document.getEle mentById('td' + taskid.toString ()
      + '8').innerText;
      submit();
      }
      }
      }

      <!----XSLT---->
      <xsl:when test="xyz/return/techrefreshs">
      <xsl:if test="xyz/return/techrefreshs/recordcount = 0">
      <div id="warning">N o record match the criteria.</div>
      </xsl:if>
      <xsl:if test="xyz/return/techrefreshs/recordcount &gt; 0">
      <form action="techRef resh.asp" method="post"
      onsubmit="retur n(fillTechRefre shForm())">
      <table class="inventor yTable" cellpadding="0" cellspacing="0" >
      <tr>
      <th>&#xA0;</th>
      <th><!--checkbox-->&#xA0;</th>
      <th><a href="javascrip t:changeSort('o rg')" title="Order by
      ORG">TASK ID</a></th>
      <th><a href="javascrip t:changeSort('t icketnum')" title="Order by
      user#">USER</a></th>
      <th><a href="javascrip t:changeSort('t icketnum')" title="Order by
      last name#">LAST NAME</a></th>
      <th><a href="javascrip t:changeSort('t icketnum')" title="Order by
      first name">FIRST NAME</a></th>
      <th><a href="javascrip t:changeSort('c _last_name')" title="Order
      by serial number">SERIAL</a></th>
      <th><a href="javascrip t:changeSort('c _first_name')" title="Order
      by scheduled date">SCHEDULED </a></th>
      <th><a href="javascrip t:changeSort('t ype')" title="Order by ready
      date">READY</a></th>
      <th><a href="javascrip t:changeSort('s tatus')" title="Order by
      deployed date">DEPLOYED</a></th>
      <th><a href="javascrip t:changeSort('o pen_date')" title="Order by
      system">NEW<br/>SYSTEM</a></th>
      <th>COMMENTS</th>
      </tr>
      <xsl:apply-templates
      select="xyz/return/techrefreshs/techrefresh"/>
      </table>
      <input type="hidden" id="txtTaskId" name="txtTaskId "/>
      <input type="hidden" id="cboUserName " name="cboUserNa me"/>
      <input type="hidden" id="txtLastName " name="txtLastNa me"/>
      <input type="hidden" id="txtFirstNam e" name="txtFirstN ame"/>
      <input type="hidden" id="cboSerial" name="cboSerial "/>
      <input type="hidden" id="txtSchedule d" name="txtSchedu led"/>
      <input type="hidden" id="txtReady" name="txtReady"/>
      <input type="hidden" id="txtDeployed " name="txtDeploy ed"/>
      <input type="hidden" id="txtNewSyste m" name="txtNewSys tem"/>
      <input type="hidden" id="txtComments " name="txtCommen ts"/>
      <input type="submit" id="btnAction" name="btnAction " value="Confirm
      Selection"/>
      </form>
      </xsl:if>
      </xsl:when>

      <xsl:template match="techrefr esh">
      <xsl:variable name="rowNumber " select="positio n()" />
      <xsl:variable name="taskid" select="taskid"/>
      <tr>
      <td style="color:#C CC;background-color:#003366"> <xsl:value-of
      select="$rowNum ber"/></td>
      <td align="center">
      <input type="radio" id="rdoSelected Task" name="rdoSelect edTask">
      <xsl:attribut e name="value"><x sl:value-of
      select="$taskid "/></xsl:attribute>
      <xsl:attribut e
      name="onclick"> document.getEle mentById("txtTa skId").value=<x sl:value-of
      select="$taskid "/></xsl:attribute>
      </input>
      </td>
      <td align="center">
      <xsl:attribut e name="id">td<xs l:value-of
      select="$taskid "/>1</xsl:attribute>
      <xsl:value-of select="$taskid "/>
      </td>
      <td>
      <xsl:attribut e name="id">td<xs l:value-of
      select="$taskid "/>2</xsl:attribute>
      <xsl:value-of select="userlog in"/>&#xA0;
      </td>
      <td>
      <xsl:attribut e name="id">td<xs l:value-of
      select="$taskid "/>9</xsl:attribute>
      <xsl:value-of select="lastnam e"/>&#xA0;
      </td>
      <td>
      <xsl:attribut e name="id">td<xs l:value-of
      select="$taskid "/>10</xsl:attribute>
      <xsl:value-of select="firstna me"/>&#xA0;
      </td>
      <td>
      <xsl:attribut e name="id">td<xs l:value-of
      select="$taskid "/>3</xsl:attribute>
      <xsl:value-of select="serial"/>&#xA0;
      </td>
      <td>
      <xsl:attribut e name="id">td<xs l:value-of
      select="$taskid "/>4</xsl:attribute>
      <xsl:value-of select="schedul ed"/>&#xA0;
      </td>
      <td>
      <xsl:attribut e name="id">td<xs l:value-of
      select="$taskid "/>5</xsl:attribute>
      <xsl:value-of select="systemr eady"/>&#xA0;
      </td>
      <td>
      <xsl:attribut e name="id">td<xs l:value-of
      select="$taskid "/>6</xsl:attribute>
      <xsl:value-of select="systemd eployed"/>&#xA0;
      </td>
      <td>
      <xsl:attribut e name="id">td<xs l:value-of
      select="$taskid "/>7</xsl:attribute>
      <xsl:value-of select="newsyst em"/>&#xA0;
      </td>
      <td>
      <xsl:attribut e name="id">td<xs l:value-of
      select="$taskid "/>8</xsl:attribute>
      <xsl:value-of select="comment s"/>&#xA0;
      </td>


      </tr>
      </xsl:template>




      *** Sent via Developersdex http://www.developersdex.com ***
      Don't just participate in USENET...get rewarded for it!

      Comment

      Working...