Jump to content
UBot Underground

Need help getting input and output to Javascript Module


Recommended Posts

Please take a look at this javascript problem... when you load the ubot and click load it will alos bring up a page giveing all the details that I am tring to do.. A copy of the javascript code that I am trying to run in the javascript module is included as a text file so you can change the extension to .htm and run it and see how the javascript works without being in the module..

I am very familiar with javascript, but not sure how to get the input and out put to it..

Anyone who can offer suggestions would be greatly appreciated..

 

See the two attachment for more details.

 

Apparently two uploads are not allowed; so here is the script to place in an htm file and run it and see how it works without the module..

 

Change to .htm and you can see the script working..<br>

I want to run this in the javascript module by

input = the outerHTML

output = desired value.

 

 

 

<script type="text/javascript">

var myString = "<SELECT> <OPTION value=1 selected>Mar 10 (100)</OPTION> <OPTION value=2>Apr 10 (100)</OPTION> <OPTION value=3>May 10 (100)</OPTION> <OPTION value=4>Jun 10 (100)</OPTION> <OPTION value=5>Jun 10 (100)</OPTION></SELECT>";

var mySplitResult = myString.split("</OPTION> ");

for(i = 0; i < mySplitResult.length; i++) {

mySplitResult;

text = mySplitResult;

mylen = text.length

bob = text.indexOf("selected")

if(bob!=-1) {

mydat = text.substring(bob+9, 50)

alert(mydat)

}

}

</script>

tool_trainer.ubot

Link to post
Share on other sites

Please take a look at this javascript problem... when you load the ubot and click load it will alos bring up a page giveing all the details that I am tring to do.. A copy of the javascript code that I am trying to run in the javascript module is included as a text file so you can change the extension to .htm and run it and see how the javascript works without being in the module..

I am very familiar with javascript, but not sure how to get the input and out put to it..

Anyone who can offer suggestions would be greatly appreciated..

 

See the two attachment for more details.

 

Apparently two uploads are not allowed; so here is the script to place in an htm file and run it and see how it works without the module..

 

Change to .htm and you can see the script working..<br>

I want to run this in the javascript module by

input = the outerHTML

output = desired value.

 

 

 

<script type="text/javascript">

var myString = "<SELECT> <OPTION value=1 selected>Mar 10 (100)</OPTION> <OPTION value=2>Apr 10 (100)</OPTION> <OPTION value=3>May 10 (100)</OPTION> <OPTION value=4>Jun 10 (100)</OPTION> <OPTION value=5>Jun 10 (100)</OPTION></SELECT>";

var mySplitResult = myString.split("</OPTION> ");

for(i = 0; i < mySplitResult.length; i++) {

mySplitResult;

text = mySplitResult;

mylen = text.length

bob = text.indexOf("selected")

if(bob!=-1) {

mydat = text.substring(bob+9, 50)

alert(mydat)

}

}

</script>

 

 

Here is your java wrapped up so that it returns the data. If the regex stuff worked correctly you can do this in about 3 lines of code but it doesnt recognize groups for some reason.

 

Hope this helps.

 

Dave

date_option.ubot

Link to post
Share on other sites

Thanks The_Brit,

That is the second time you saved my life, but you left out one important part..

IF you look back at the rig, I first scraped the dropdown and got the data in the incoming variable..

In my example i had shown the input as a variable already in the javascript.. since I did not know how to get it into the module...

So you sloved one problem: that of getting the result... but that still leaves the problem of taking the scraped data into the javascript module..

You are the best.... thanks..

 

In other words:

var myString = "<SELECT> <OPTION value=1 selected>Mar 10 (100)</OPTION> <OPTION value=2>Apr 10 (100)</OPTION> <OPTION value=3>May 10 (100)</OPTION> <OPTION value=4>Jun 10 (100)</OPTION> <OPTION value=5>Jun 10 (100)</OPTION></SELECT>";

var mySplitResult = myString.split("</OPTION> ");

for(i = 0; i < mySplitResult.length; i++) {

mySplitResult;

text = mySplitResult;

mylen = text.length

bob = text.indexOf("selected")

if(bob!=-1) {

mydat = text.substring(bob+9, 50)

}

}

mydat+"";

 

So bottom line I need to be able to pull the outerHTML scrape into the javascript module vice using the hard wired one shown as var mystring above... hope this makes sense..

 

You completed the get data out of the module, but not the get data in....

So it will need to scrape the dropdown each time and then process it in and out of the javascript module then repeat over and over...

 

THanks for what you have done..

Link to post
Share on other sites

Thanks The_Brit,

That is the second time you saved my life, but you left out one important part..

IF you look back at the rig, I first scraped the dropdown and got the data in the incoming variable..

In my example i had shown the input as a variable already in the javascript.. since I did not know how to get it into the module...

So you sloved one problem: that of getting the result... but that still leaves the problem of taking the scraped data into the javascript module..

You are the best.... thanks..

 

In other words:

var myString = "<SELECT> <OPTION value=1 selected>Mar 10 (100)</OPTION> <OPTION value=2>Apr 10 (100)</OPTION> <OPTION value=3>May 10 (100)</OPTION> <OPTION value=4>Jun 10 (100)</OPTION> <OPTION value=5>Jun 10 (100)</OPTION></SELECT>";

var mySplitResult = myString.split("</OPTION> ");

for(i = 0; i < mySplitResult.length; i++) {

mySplitResult;

text = mySplitResult;

mylen = text.length

bob = text.indexOf("selected")

if(bob!=-1) {

mydat = text.substring(bob+9, 50)

}

}

mydat+"";

 

So bottom line I need to be able to pull the outerHTML scrape into the javascript module vice using the hard wired one shown as var mystring above... hope this makes sense..

 

You completed the get data out of the module, but not the get data in....

So it will need to scrape the dropdown each time and then process it in and out of the javascript module then repeat over and over...

 

THanks for what you have done..

 

I actually did scrape the HTML directly using JavaScript when I did it but due to some problem in our JavaScript module, additional processing other than displaying it as a string fails. For example, attempting to do string.length on the scraped HTML returns a 1. Anyway, for reference you can scrape the HTML by using the DOM

 

string = document.GetElementByID("element_id").innerHTML;

 

If it had worked then you could achieve all of what you had to go through in about 3 lines of code. Even the regex doesn't work properly as it doesn't process ignore groups at all.

 

Thanks

 

Dave

Link to post
Share on other sites

I actually did scrape the HTML directly using JavaScript when I did it but due to some problem in our JavaScript module, additional processing other than displaying it as a string fails. For example, attempting to do string.length on the scraped HTML returns a 1. Anyway, for reference you can scrape the HTML by using the DOM

 

string = document.GetElementByID("element_id").innerHTML;

 

If it had worked then you could achieve all of what you had to go through in about 3 lines of code. Even the regex doesn't work properly as it doesn't process ignore groups at all.

 

Thanks

 

Dave

 

Here is a revised version using the DOM plus regex

 

Dave

using_regex.ubot

Link to post
Share on other sites

Where did you get this ID? frmExpSpc0_0

 

match = document.getElementById("frmExpSpc0_0").innerHTML;

 

Is that the actual ID that Tool Trainer is using in the project he is working?

I don't have access to his log in.. so to see this work all I need to do is add this id to my dropdown that I used for simulation... is that correct?

 

 

Also this should scrape using all the other getElements also corrrect?

Link to post
Share on other sites

Where did you get this ID? frmExpSpc0_0

 

match = document.getElementById("frmExpSpc0_0").innerHTML;

 

Is that the actual ID that Tool Trainer is using in the project he is working?

I don't have access to his log in.. so to see this work all I need to do is add this id to my dropdown that I used for simulation... is that correct?

 

 

Also this should scrape using all the other getElements also corrrect?

Yes, it is the actual ID of the drop-down. I used the ID option in the list of available attributes when viewing the drop-downs properties in UBot. The ID is specific to the particular element but yes if you are on the sae page as TT was viewing, it will work. You can also replace that ID with one from any other page and it will retrieve the innerHTML data.

 

Dave

Link to post
Share on other sites

Hi Dave,

Still having problems... to see it work like I added the ID to my dropdown and it says can't replace.

Set

#new String

#Replace

#HTML

selected>

Replace

 

I sent the bot with the file name attached... I added a selected in the drop down to make it acutally select something... did that mess it up... its not unusual for the dropdown to come in with a specific item selected.

 

Its giveing the error.. Cannot Replace..

using_regex_fileadded.ubot

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...