i have a textfile whic is actually a html code and i want to pass the variable value into one of the textbox in the codefile.
Variable is : varamountDue with default value “100”
The textbox where i want to pass this variable in the code is
input type=“number” id=“amountDue” required=“true” name=“amountDue” placeholder=“0.01”
in the id attribute i want to pass this variable : varamountDue HTMLPage1.html (5.6 KB)
@somya177
When you post code put a backslash before the tags to escape them:
<input type=“number” id=“amountDue” required=“true” name=“amountDue” placeholder=“1.0” step=“0.01” min=“0”>
You can also mark it as preformatted text and it will show like this: <input type="number" id="amountDue" required="true" name="amountDue" placeholder="1.0" step="0.01" min="0">
To put the variable in your html file do the following:
Use a Read Text File activity to read your html into a string variable, let’s call it fileText. Then use fileText.Replace to replace the placeholder text with your variable value. Finally, write the modified to text back to the file with a Write Text File activity.
@somya177
In that case you would do fileText.Replace("@vamountDue",varamountDue). Note the quotation marks - this will replace any copies of “@vamountDue” with whatever value is in varamountDue. If varamountDue is a numerical type then you will need to use varamountDue.ToString in order to write it to the file.
but this will be blank like this <input type="number" id="amountDue" required="true" name="amountDue" placeholder="1.0" step="0.01" min="0">
Bot has to fetch value from webpage ,save it in vamountDue and pass this into this textbox of Customform
@somya177
The html file is just text, you can make the placeholder value anything that you want. Get rid of that “1.0” value and put some placeholder text in there. Then modify the file with Replace before you open it with the custom form activity.
i tried this in Write Text File activity customOutput.Replace(“placeholder=test”,“placeholder=”+vtest)
where vtest=100 but still it didn’t ammend the placeholder value to be 100
@somya177
This does modify the file so to keep being able to fill in the placeholder you should have a “base” copy and a “modified” copy so that the original always has the placeholder text. Otherwise the replace won’t work.
it worked for me once, but I want the BOT to overwrite the newvalue passed through inputdialog overwrite the previous value.But it is not overwriting that