3

I am working on a project that i would need to populate textbox's inside of BMC Web Remedy with information with JavaScript/HTA File. -- Essentially I just need to Push text into textbox's on the site

I can't seem to figure out how to populate the information onto the page itself though, was wondering if I could get some guidance of if this is possible/how i would go about doing this, or just pointed in the right direction.

Just to clarify as an example on the web site: http://www.brivers.com/resume/scripts/tutorial-hta-textbox.php

Having data push into the name/address/city field

Something like this only I'm not sure how to push it to the website field itself

**sorry just to clarify the field I am wanting to push this to is external of the application, is there a way to push this to a text field on (literally any) website? for example a username/password textbox on any site

<script language="javascript" type="text/javascript">
function PushData_NSO(){
var userinput = txtPhoneNum.value;
document.getElementById('txtName').value = userinput;
}
</script>


<body>
<p> <input id="txtPhoneNum" type="text" value=""> </p>
<p> <input type="button" onclick="PushData_NSO()"> </p>
</body>

6 Answers 6

1

You're trying to do getElementById('txtName') where the html is <input id="txtPhoneNum" />. This will never work because the id isn't the same as the one you're trying to access.

For errors like this, you could use the developer tools (Chrome, IE, Firefox shortcut F12) to see if there are errors in the console.

Furthermore the variable txtPhoneNum isn't defined. If you'd want it to be the input-element you should first do txtPhoneNum = document.getElementById('txtPhoneNum').

I've created a plunker to illustrate.

Sign up to request clarification or add additional context in comments.

2 Comments

This much I understand, I just am not sure how to have it push to the site because it's external. I know how to push from textbox to textbox within my own application, but how would I do it onto an external site? Not sure if i'm being entirely clear sorry! (also thank you for the examples!)
What do you mean by 'external'. Javascript can only execute inside the current document. Or use XHTMLHttpRequest to communicate with the server.
0

Get the data from HTML like this,

var userinput = document.getElementById('txtPhoneNum').value;
// do something with userinput

To display data in HTML you should use,

document.getElementById("whateverID").innerHTML = "changed user input"; 

Comments

0

try this:

<script type="text/javascript">

function PushData_NSO(){
var userinput = document.getElementById('txtPhoneNum').value;
document.getElementById('txtName').value = userinput;
}
</script>


<body>
<p> <input id="txtPhoneNum" type="text" value=""> </p>
  <input type="text" id="txtName" value="" />

<input type="button" onclick="PushData_NSO()" value="push "/>
</body>

Comments

0

When you use getElementById('ValueOfID'), the javascript searches all the elements in the html where the id attribute is the same value as "ValueOfID" (in this case).

The .value after getElementById means you are going to do something with that value, in this case you change it to whatever is in the "userinput" variable.

So in your case you need to do:

<script language="javascript" type="text/javascript">
function PushData_NSO(){
var userinput = txtPhoneNum.value;
document.getElementById('txtPhoneNum').value = userinput;
}
</script>

Comments

0

Please try this:

<script language="javascript" type="text/javascript">
  function PushData_NSO(){

      //First get the value or text, for an instance, just say "sampleText".
       var userinput = document.getElementById('txtPhoneNum').value;


      //Secondly get the id of the textbox and using that append the value to that textbox.
       document.getElementById('txtName').value = userinput;
  }
</script>

2 Comments

not sure if i'm misunderstanding or conveying it incorrectly. The textbox I make is the data i want to enter into the textbox. on the website. but how do I push this to the site. In this example the site is brivers.com/resume/scripts/tutorial-hta-textbox.php and the textbox I want to push my value into (on the brivers site) is labelled as <input type="text" id="txtName" value="" />
Sorry i didn't get u, pls explain.
0

I think this is what your after

<form>
    <input id="txtPhoneNum" type="text" value=""/>
    <input type="button" onclick="PushData_NSO()" value="Add Number to Div"/>
</form>
<br/>
<div id="txt">The number will replace this text</div>

<script>
function PushData_NSO(){
    var userinput = document.getElementById('txtPhoneNum').value
    document.getElementById('txt').innerHTML = userinput;
}
</script>

Here is a JSFIDDLE showing it in action, if you have any questions about this feel free to ask

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.