pelkeyms

Unable to setvalue of textarea

22 posts in this topic

This is my first time ever posting any question on any forum. I know that there are strict rules and ways of posting but I'm not sure what they all are. Please bear with me. I am writing a script to populate a SharePoint form with data. I am able to populate the drop down boxes and the single line text inputs with no issues. However I am unable to populate the multiline textareas. Furthermore I am unable to perform any action on these textareas successfully. I have tried using focus and scrollintoview on them as well but nothing works. Below is the html that pertains to this element.

<tr>
        <td nowrap="true" valign="top" width="190px" class="ms-formlabel"><h3 class="ms-standardheader">
        <nobr>Justification for Change Request<span class="ms-formvalidation" title="This is a required field." > *</span></nobr>
    </h3></td>
        <td valign="top" class="ms-formbody">
        <!-- FieldName="Justification for Change Request"
             FieldInternalName="Justification_x0020_for_x0020_Re"
             FieldType="SPFieldNote"
          -->
            <span dir="none">
        <span dir="ltr">
            <textarea name="ctl00$m$g_6c1feacd_cfd3_4c2f_b1d6_29e6cb2b0e3a$ctl00$ctl05$ctl20$ctl00$ctl00$ctl04$ctl00$ctl00$TextField" rows="6" cols="20" id="ctl00_m_g_6c1feacd_cfd3_4c2f_b1d6_29e6cb2b0e3a_ctl00_ctl05_ctl20_ctl00_ctl00_ctl04_ctl00_ctl00_TextField" title="Justification for Change Request Required Field" class="ms-long" dir="none"></textarea>
            <input name="ctl00$m$g_6c1feacd_cfd3_4c2f_b1d6_29e6cb2b0e3a$ctl00$ctl05$ctl20$ctl00$ctl00$ctl04$ctl00$ctl00$TextField_spSave" type="HIDDEN" id="ctl00_m_g_6c1feacd_cfd3_4c2f_b1d6_29e6cb2b0e3a_ctl00_ctl05_ctl20_ctl00_ctl00_ctl04_ctl00_ctl00_TextField_spSave" />
        </span>
    <script type="text/javascript">// <![CDATA[
if (browseris.ie5up && (browseris.win32 || browseris.win64bit) && !IsAccessibilityFeatureEnabled()){RTE_ConvertTextAreaToRichEdit("ctl00_m_g_6c1feacd_cfd3_4c2f_b1d6_29e6cb2b0e3a_ctl00_ctl05_ctl20_ctl00_ctl00_ctl04_ctl00_ctl00_TextField", true, true, "", "1033", null, true, null, null, null,"Compatible", "\u002fsites\u002fdev\u002fDocketOperations",null,null,null,null);}else{document.write(" <br /><span class=\"ms-formdescription\"><a href='javascript:HelpWindowKey(\"nsrichtext\")'>Click for help about adding basic HTML formatting.</a></span> <br />");};//]]>
</script></span>
            Please provide justification for this Docket Change Request.
            
        </td>
    </tr>

 

I have tried many ways of interacting with this text area and setting the value. Below is the current attempt. Nothing has worked. When I call the _IEFormElementGetValue below it reads me back the text I tried to insert but it's not visible anywhere on the page. The fact that I can't get focus or scroll to work either has me thinking I'm really missing something major. I haven't been able to find any posts that help. Please help me.

Local $oForm = _IEFormGetObjByName($oIE, "aspnetForm")
 Local $oQuery = _IEFormElementGetCollection($oForm)
 Local $iNumElements = @extended
 Local $oElement
 For $i = 0 To $iNumElements - 1
    $oElement = _IEFormElementGetCollection($oForm, $i)
    Switch $oElement.name
   Case "ctl00$m$g_6f93c57b_dbe2_4569_b95f_a63717bfc19e$ctl00$ctl05$ctl20$ctl00$ctl00$ctl04$ctl00$ctl00$TextField"
   ;Case "ctl00$m$g_6f93c57b_dbe2_4569_b95f_a63717bfc19e$ctl00$ctl05$ctl20$ctl00$ctl00$ctl04$ctl00$ctl00$TextField_spSave"
      _IEFormElementSetValue($oElement, "This is a test")
      local $stext = _IEFormElementGetValue($oElement)
      _IEAction($oElement, "focus")
      ;ControlSend($hWnd, "", "[TITLE: Docket Change Request Log]", "This is a test")
      _IEAction($oElement, "scrollintoview")
      MsgBox($MB_SYSTEMMODAL, "Element Info", $sText)
   EndSwitch

 

Share this post


Link to post
Share on other sites



Unfortunately I already tried doing it that way as well. Same results. I want to understand though. Does that example do anything differently than the original code I posted? It uses the _IEGetObjByName but that really just gets you the textarea element, which my code did as well. It's essentially doing the same thing right?

Share this post


Link to post
Share on other sites

Have you checked if you are getting the element ? And why you are looping through every single element in $oForm ?

Can you share the URL?

Have you tried to change the example to the website that you want to change the textarea?

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

if I remember well, this should be like this:

$oTextArea.innerHtml = $sYourHtml

or like this:

$oTextArea.innerText = $sYourText

EDIT:

to check how to solve the problem make this steps:

  1. enter manually some text i.e. "Hello World" in this text area
  2. inspect this item in IE
  3. copy HTML snippet containg "Hello World"
  4. paste it to the forum

The sombody be able to find a way to do it with AutoIt.

 

mLipok

 

Edited by mLipok

Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2017-06-04

Share this post


Link to post
Share on other sites

I can't share the URL because it is part of a firewalled site. It is probably a lot of overhead to keep looping through every element each time but that way I am able to search on the elements based on the title, which is much shorter and more manageable than the name. I just changed the code to search on the name for this one field since I was having trouble with it (at first I didn't know if I should be working with the textarea or the input and the input didn't have a title).

Here is the html with text in the box as requested . I tried to manually set the value to "<div>This is a test. </div>" at one point as well. It also didn't work.

<tr>
        <td nowrap="true" valign="top" width="190px" class="ms-formlabel"><h3 class="ms-standardheader">
        <nobr>Justification for Change Request<span class="ms-formvalidation" title="This is a required field." > *</span></nobr>
    </h3></td>
        <td valign="top" class="ms-formbody">
        <!-- FieldName="Justification for Change Request"
             FieldInternalName="Justification_x0020_for_x0020_Re"
             FieldType="SPFieldNote"
          -->
            <span dir="none">
        <span dir="ltr">
            <textarea name="ctl00$m$g_6c1feacd_cfd3_4c2f_b1d6_29e6cb2b0e3a$ctl00$ctl05$ctl20$ctl00$ctl00$ctl04$ctl00$ctl00$TextField" rows="6" cols="20" id="ctl00_m_g_6c1feacd_cfd3_4c2f_b1d6_29e6cb2b0e3a_ctl00_ctl05_ctl20_ctl00_ctl00_ctl04_ctl00_ctl00_TextField" title="Justification for Change Request Required Field" class="ms-long" dir="none"><div>This is a test. </div></textarea>
            <input name="ctl00$m$g_6c1feacd_cfd3_4c2f_b1d6_29e6cb2b0e3a$ctl00$ctl05$ctl20$ctl00$ctl00$ctl04$ctl00$ctl00$TextField_spSave" type="HIDDEN" id="ctl00_m_g_6c1feacd_cfd3_4c2f_b1d6_29e6cb2b0e3a_ctl00_ctl05_ctl20_ctl00_ctl00_ctl04_ctl00_ctl00_TextField_spSave" />
        </span>
    <script type="text/javascript">// <![CDATA[
if (browseris.ie5up && (browseris.win32 || browseris.win64bit) && !IsAccessibilityFeatureEnabled()){RTE_ConvertTextAreaToRichEdit("ctl00_m_g_6c1feacd_cfd3_4c2f_b1d6_29e6cb2b0e3a_ctl00_ctl05_ctl20_ctl00_ctl00_ctl04_ctl00_ctl00_TextField", true, true, "", "1033", null, true, null, null, null,"Compatible", "\u002fsites\u002fdev\u002fDocketOperations",null,null,null,null);}else{document.write(" <br /><span class=\"ms-formdescription\"><a href='javascript:HelpWindowKey(\"nsrichtext\")'>Click for help about adding basic HTML formatting.</a></span> <br />");};//]]>
</script></span>
            Please provide justification for this Docket Change Request.
            
        </td>
    </tr>

 

Share this post


Link to post
Share on other sites

Your manually aproach is not right. And looping though every element is not the best way (probably neither the fastest one), but you can deal with this later.

Lets try something here ok? Open the website (make sure that there is not other ie istance) and use this code alone. I need you to manually check and confirm if the element ID of the textarea is correct. Also please check and confirm if there is a framset in the website, just try to find this strings inside the html "iframe" or "frame".

#include <IE.au3>

MsgBox(0, "", "Make sure there is not other IE instance and the website if fully loadded.")

Local $oIE = _IEAttach("", "instance", 1)
If Not IsObj($oIE) Then Exit ConsoleWrite("Error in $oIE" & @CRLF)

Local $oTextArea = $oIE.document.getElementById("ctl00_m_g_6c1feacd_cfd3_4c2f_b1d6_29e6cb2b0e3a_ctl00_ctl05_ctl20_ctl00_ctl00_ctl04_ctl00_ctl00_TextField")
If Not IsObj($oTextArea) Then Exit ConsoleWrite("Error in $oTextArea" & @CRLF)

$oTextArea.Value = "Hello World!"

ConsoleWrite($oTextArea.Title & @CRLF)
ConsoleWrite($oTextArea.Name & @CRLF)

Exit

Paste the console output here. If this does not work, do what @mLipok suggested, write something in the textarea then open the html and copy the code.

Share this post


Link to post
Share on other sites

 

6 hours ago, pelkeyms said:

<textarea name="ctl00$m$g_6c1feacd_cfd3_4c2f_b1d6_29e6cb2b0e3a$ctl00$ctl05$ctl20$ctl00$ctl00$ctl04$ctl00$ctl00$TextField" rows="6" cols="20" id="ctl00_m_g_6c1feacd_cfd3_4c2f_b1d6_29e6cb2b0e3a_ctl00_ctl05_ctl20_ctl00_ctl00_ctl04_ctl00_ctl00_TextField" title="Justification for Change Request Required Field" class="ms-long" dir="none"><div>This is a test. </div></textarea>

try this:

; first approach
Local $oDiv1 = $oTextArea.nextElementSibling
$oDiv1.innerText = 'Hello World'

; second approach
Local $oDiv2 = $oTextArea.nextSibling
$oDiv2.innerText = 'Hello World'

 


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2017-06-04

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Ok, I actually have it kind of working now. Thank you very much for your help so far. I say kind of because attached is how it appears when I set the value. The textarea next to CER Impact Details is how it should appear. But you can see the input area has gone away in the area next to Justification for Change Request. However the value is set to "This is a test." It allows me to submit the form and from then on it appears correctly in both view and edit. Any thoughts on how to get it to appear correctly for the initial set? Below is the code I'm using to get the attached. I had to get the next next sibling. I still cant get the scroll or focus to work which still makes me feel like there is something that I'm missing.

Local $oTextArea = _IEGetObjByName($oIE, "ctl00$m$g_6f93c57b_dbe2_4569_b95f_a63717bfc19e$ctl00$ctl05$ctl20$ctl00$ctl00$ctl04$ctl00$ctl00$TextField")
; second approach
Local $oDiv2 = $oTextArea.nextSibling
Local $oDiv3 = $oDiv2.nextSibling
;Local $oDiv4 = $oDiv3.nextSibling
$oDiv3.innerHtml = "This is a test."

;_IEFormElementSetValue($oTextArea, "Hey! This works!")
;$oTextArea.innerHtml = "<div>This is a test. </div>"
;$oTextArea.innerText = "<div>This is a test. </div>"
_IEAction($oElement, "scrollintoview")
_IEAction($oElement, "focus")

; first approach
;Local $oDiv1 = $oTextArea.nextElementSibling
;$oDiv1.innerText = 'Hello World'

 

Capture.PNG

Edited by pelkeyms

Share this post


Link to post
Share on other sites

Add your text and get outerHTML

$oDiv3.innerHtml = "This is a test."
ClipPut($oTextArea.outerHTML)

After that post here clipboard content.


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2017-06-04

Share this post


Link to post
Share on other sites

Ok, I'm getting closer. I did what you suggested and saw that the textarea had display set to none. I changed that to block with the following code:

Local $oTextArea = _IEGetObjByName($oIE, "ctl00$m$g_6f93c57b_dbe2_4569_b95f_a63717bfc19e$ctl00$ctl05$ctl20$ctl00$ctl00$ctl04$ctl00$ctl00$TextField")
;Local $oDiv2 = $oTextArea.nextSibling
;Local $oDiv3 = $oDiv2.nextSibling
;$oDiv3.innerHtml = "This is a test."
$oTextArea.value = "This is a test."
$oTextArea.style.display = "block"
ClipPut($oTextArea.outerHTML)

It gives the following outerHTML:

<TEXTAREA name=ctl00$m$g_6f93c57b_dbe2_4569_b95f_a63717bfc19e$ctl00$ctl05$ctl20$ctl00$ctl00$ctl04$ctl00$ctl00$TextField title="Justification for Change Request Required Field" class=ms-long id=ctl00_m_g_6f93c57b_dbe2_4569_b95f_a63717bfc19e_ctl00_ctl05_ctl20_ctl00_ctl00_ctl04_ctl00_ctl00_TextField style="DISPLAY: block" rows=6 cols=20>This is a test.</TEXTAREA>

But unfortunately it appears as shown in the attachment, with an extra textbox. This makes me think that instead of dealing with the textarea, maybe I should be dealing with the associated input element referenced in this html.

<tr>
        <td nowrap="true" valign="top" width="190px" class="ms-formlabel"><h3 class="ms-standardheader">
        <nobr>Justification for Change Request<span class="ms-formvalidation" title="This is a required field." > *</span></nobr>
    </h3></td>
        <td valign="top" class="ms-formbody">
        <!-- FieldName="Justification for Change Request"
             FieldInternalName="Justification_x0020_for_x0020_Re"
             FieldType="SPFieldNote"
          -->
            <span dir="none">
        <span dir="ltr">
            <textarea name="ctl00$m$g_6f93c57b_dbe2_4569_b95f_a63717bfc19e$ctl00$ctl05$ctl20$ctl00$ctl00$ctl04$ctl00$ctl00$TextField" rows="6" cols="20" id="ctl00_m_g_6f93c57b_dbe2_4569_b95f_a63717bfc19e_ctl00_ctl05_ctl20_ctl00_ctl00_ctl04_ctl00_ctl00_TextField" title="Justification for Change Request Required Field" class="ms-long" dir="none"></textarea>
            <input name="ctl00$m$g_6f93c57b_dbe2_4569_b95f_a63717bfc19e$ctl00$ctl05$ctl20$ctl00$ctl00$ctl04$ctl00$ctl00$TextField_spSave" type="HIDDEN" id="ctl00_m_g_6f93c57b_dbe2_4569_b95f_a63717bfc19e_ctl00_ctl05_ctl20_ctl00_ctl00_ctl04_ctl00_ctl00_TextField_spSave" />
        </span>
    <script type="text/javascript">// <![CDATA[
if (browseris.ie5up && (browseris.win32 || browseris.win64bit) && !IsAccessibilityFeatureEnabled()){RTE_ConvertTextAreaToRichEdit("ctl00_m_g_6f93c57b_dbe2_4569_b95f_a63717bfc19e_ctl00_ctl05_ctl20_ctl00_ctl00_ctl04_ctl00_ctl00_TextField", true, true, "", "1033", null, true, null, null, null,"Compatible", "\u002fsites\u002fdev\u002fDocketOperations",null,null,null,null);}else{document.write("&#160;<br /><span class=\"ms-formdescription\"><a href='javascript:HelpWindowKey(\"nsrichtext\")'>Click for help about adding basic HTML formatting.</a></span>&#160;<br />");};//]]>
</script></span>
            Please provide justification for this Docket Change Request.
            
        </td>
    </tr>

I'm not sure where the attachment is going to appear so in order to cut down on confusion I will make a separate post with my findings trying to use the input element.

 

Capture2.PNG

Share this post


Link to post
Share on other sites

Then I used the following code to try to set the input element value, type, and display style. Note, I'm using the same variable name but I have changed the _IEGetObjByName to grab the input element instead of the textarea.

Local $oTextArea = _IEGetObjByName($oIE, "ctl00$m$g_6f93c57b_dbe2_4569_b95f_a63717bfc19e$ctl00$ctl05$ctl20$ctl00$ctl00$ctl04$ctl00$ctl00$TextField_spSave")
;Local $oDiv2 = $oTextArea.nextSibling
;Local $oDiv3 = $oDiv2.nextSibling
;$oDiv3.innerHtml = "This is a test."
$oTextArea.value = "This is a test."
$oTextArea.type = "text"
$oTextArea.style.display = "block"
ClipPut($oTextArea.outerHTML)

However, for some reason setting the type to text doesn't take. You can see in the below resulting outerHTML:

<INPUT name=ctl00$m$g_6f93c57b_dbe2_4569_b95f_a63717bfc19e$ctl00$ctl05$ctl20$ctl00$ctl00$ctl04$ctl00$ctl00$TextField_spSave id=ctl00_m_g_6f93c57b_dbe2_4569_b95f_a63717bfc19e_ctl00_ctl05_ctl20_ctl00_ctl00_ctl04_ctl00_ctl00_TextField_spSave style="DISPLAY: block" type=hidden value="This is a test.">

And nothing happens in the form. The field appears completely empty like nothing has happened. See attached. So as you can see, I'm making some progress by trying to set the attributes of the elements directly but I'm still not able to get it quite right. Also, does anyone know why I can't just do this the same way I did it for all of the other drop down and single line input fields like I did below? That code works for all of the other types of fields.

Local $oForm = _IEFormGetObjByName($oIE, "aspnetForm")
 Local $oQuery = _IEFormElementGetCollection($oForm)
 Local $iNumElements = @extended
 Local $oElement
 For $i = 0 To $iNumElements - 1
    $oElement = _IEFormElementGetCollection($oForm, $i)
    Switch $oElement.title
    Case "Status Required Field"
       _IEFormElementSetValue($oElement, "In progress")
    Case "Request Type Required Field"
       _IEFormElementSetValue($oElement, "Docket Addition")
    Case "Subsegment Required Field"
       _IEFormElementSetValue($oElement, "DCS")
   Case "Project Name Required Field"
       _IEFormElementSetValue($oElement, "Michelle's Test Project")
   Case "Project ID Required Field"
       _IEFormElementSetValue($oElement, "1615")
   Case "Stage Required Field"
       _IEFormElementSetValue($oElement, "2")
   Case "Current  CAL YR Budget Required Field"
       _IEFormElementSetValue($oElement, "0")
   Case "Proposed  CAL YR Budget Required Field"
       _IEFormElementSetValue($oElement, "100000")
    EndSwitch

 

Capture3.PNG

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

This is not "Value"

You should use:

$oTextArea.innerHtml = $sYourHtml

or like this:

$oTextArea.innerText = $sYourText

 

eventualy:

$oDiv.innerHtml = $sYourHtml

or like this:

$oDiv.innerText = $sYourText
Edited by mLipok

Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2017-06-04

Share this post


Link to post
Share on other sites

I've done it using innerHtml instead of value as well but the results were the same.

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

Can you say which one HTML OnLine Editor you are using ?
Or which CRM like software you are using ?
I remember that I saw this Editor somewhere.

EDIT: to be more precise:  Which WYSIWYG HTML RICH TEXT EDITOR you are using ?

Edited by mLipok

Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2017-06-04

Share this post


Link to post
Share on other sites

Work with the input . Reference this :

            <input name="ctl00$m$g_6f93c57b_dbe2_4569_b95f_a63717bfc19e$ctl00$ctl05$ctl20$ctl00$ctl00$ctl04$ctl00$ctl00$TextField_spSave" type="HIDDEN" id="ctl00_m_g_6f93c57b_dbe2_4569_b95f_a63717bfc19e_ctl00_ctl05_ctl20_ctl00_ctl00_ctl04_ctl00_ctl00_TextField_spSave" />

And use ;

$oInputs = _IETagNameGetCollection($oIE, "input")
For $oInput In $oInputs
    MsgBox(0, "Form Input Type", "ID: " & $oInput.id & " Name: " & $oInput.name)
Next

Because the text area has the same name and _IEGetObjByName will be getting the text area.

Share this post


Link to post
Share on other sites

this is the nice code

Share this post


Link to post
Share on other sites
1 hour ago, Juvigy said:

Work with the input . 

@Juvigy do you have acces to the same HTML RTE ?

Different HTML RTE does the job in different way.

 


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2017-06-04

Share this post


Link to post
Share on other sites

RTE is irrelevant in this particular case.

Share this post


Link to post
Share on other sites
3 hours ago, Juvigy said:

Because the text area has the same name and _IEGetObjByName will be getting the text area.

<textarea name="ctl00$m$g_6c1feacd_cfd3_4c2f_b1d6_29e6cb2b0e3a$ctl00$ctl05$ctl20$ctl00$ctl00$ctl04$ctl00$ctl00$TextField" ......
  <input name="ctl00$m$g_6c1feacd_cfd3_4c2f_b1d6_29e6cb2b0e3a$ctl00$ctl05$ctl20$ctl00$ctl00$ctl04$ctl00$ctl00$TextField_spSave"  ......

They are not the same   <input name="....._spSave"

 


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2017-06-04

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now