Page 2 of 3 <123>
Topic Options
#105525 - 2003-10-15 04:14 AM Re: Is it possible to update a web page with a KiXtart script?
jacks73 Offline
Getting the hang of it

Registered: 2003-04-23
Posts: 58
No luck with the amended URL. This is a secure web page (https) I added the "s" to your suggestion but to no avail. Unfortunately your URL isn't passing the login parameters. I've got an idea for a workaround solution, which is to have the script ask and make sure the site has been logged into before running the update on the second page because as I said in a previous post I can open a second instance of the 2nd
Top
#105526 - 2003-10-15 04:56 AM Re: Is it possible to update a web page with a KiXtart script?
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
the whole point in the URL was to pass the params.
and they are absolutely going there.
you just need to write the correct info in there.
_________________________
!

download KiXnet

Top
#105527 - 2003-10-17 12:48 AM Re: Is it possible to update a web page with a KiXtart script?
jacks73 Offline
Getting the hang of it

Registered: 2003-04-23
Posts: 58
GOT IT!

It took two commands to submit the form. Thanks Lonkero, for keeping me thinking.

code:
Break On

$ID = 'name'

$PW = 'pwd'


$URL = "https://169.218.223.124/script/lb_login.asp"

$IE = CreateObject("InternetExplorer.Application")

$IE.Visible = 1

$IE.Navigate($URL)

While $IE.Busy and $IE.ReadyState <> 4 and @ERROR = 0 Loop

$IE.Document.getelementbyid("custid").Value = $ID

$IE.Document.getelementbyid("pw").Value = $PW

$IE.Document.lblogin.posting.value = 1

$IE.Document.lblogin.Submit()


Exit 0

[Eek!] Now, on to stage two...

Top
#105528 - 2003-10-17 07:01 AM Re: Is it possible to update a web page with a KiXtart script?
jacks73 Offline
Getting the hang of it

Registered: 2003-04-23
Posts: 58
I pretty much have the rest of my script written but I have another question.

if:

$pts = '5.5'
or:
$pts = '5.51'

How do I append the zeros to the end of the value so that whatever the value of $pts I will always have a number to 3 decimals?
The value of $pts comes from a "gets" statement.

[ 17. October 2003, 07:04: Message edited by: jacks73 ]

Top
#105529 - 2003-10-17 08:07 AM Re: Is it possible to update a web page with a KiXtart script?
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
lol, your working code is just what I gave you with the URL.
just that you wanted to write a script to make an URL call to webserver.

well, as you wish.

how to add zeros?
how about:
$val=$val+0

[Wink]
btw, the val indeed needs to be a string just like showed.

oh...
if you don't know the length of the string, how aboot:
left($basta+"00",3)

once again on silver platter...
that's all in the manual.
_________________________
!

download KiXnet

Top
#105530 - 2003-10-17 09:55 AM Re: Is it possible to update a web page with a KiXtart script?
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Look up "FormatNumber()" in the manual.
Top
#105531 - 2003-10-18 07:01 PM Re: Is it possible to update a web page with a KiXtart script?
jacks73 Offline
Getting the hang of it

Registered: 2003-04-23
Posts: 58
Lonkero,
I know your url probably should have worked but I couldn't get it to.

Richard,
Thanks for pointing me to formatnumber it is just what I needed.

here's the code that I have so far
code:
 Break On

$ID = 'name'

$PW = 'pwd'

do
?'Enter 30 Year Fixed Conforming Rate>' gets $rte44
until $rte44
do
?'Enter 30 Year Fixed Conforming Points>' gets $pts44
until $pts44
do
?'Enter 30 Year Fixed Conforming APR (Enter X to auto calculate)>' gets $apr44
until $apr44
do
?'Enter 30 Year Fixed Conforming lock>' gets $lck44
until $lck44

if $apr44 = 'x'
$apr44 = ''
else
$apr44=formatnumber($apr44,3)
endif


$rte44=formatnumber($rte44,3)
$pts44=formatnumber($pts44,3)

:time
do
?'Please enter the update frequency for today (5,10,15)>' gets $sleep
until $sleep

if $sleep <> 5
if $sleep <> 10
if $sleep <> 15
?'Updates can only be preformed at 5, 10, or 15 min intervals please re-enter!'
goto time
endif

:again



$URL = "https://169.218.223.168/script/lb_login.asp"

$IE = CreateObject("InternetExplorer.Application")

$IE.Visible = 1

$IE.Navigate($URL)

While $IE.Busy and $IE.ReadyState <> 4 and @ERROR = 0 Loop

$IE.Document.getelementbyid("custid").Value = $ID

$IE.Document.getelementbyid("pw").Value = $PW

$IE.Document.lblogin.posting.value = 1

$IE.Document.lblogin.Submit()

$IE.Document.getelementbyid("4004rate").Value = "$rte44"
$IE.Document.getelementbyid("4004points").Value = "$Pts44"
$IE.Document.getelementbyid("4004apr").Value = "$apr44"
$IE.Document.getelementbyid("4004lock").Value = "$lck44"

$IE.document.fixrates.posting.value = 1
$IE.document.fixrates.submit()

sleep 2

$url2='https://169.218.223.168/script/adjrates.asp'


$IE.Navigate($URL2)

$val = 2

sleep 2

$IE.Document.getelementbyid(4006index)."option value" = $val;dropdown box

$IE.document.adjrates.posting.value = 1
$IE.document.adjrates.submit()

if $sleep=5
sleep 300
endif
if $sleep=10
sleep 600
endif
if $sleep=15
sleep 900
endif

call var_rate.kix

if @TIME <> '4:*:*'
goto again
endif

Exit 0

My next problem is how to select an option from the dropdown box.
I've tried
code:
 $IE.Document.getelementbyid(4006index).option = $val
$IE.Document.getelementbyid(4006index).value = $val

but none will access any of the options. Any ideas

here's the segment of the html that defines it

code:
 <td width="86"> 
<select name="4006index" size="1" onBlur="onBlur_Checkvalue(this,8)">

<option value="1" selected >1Yr TBill</option>

<option value="2" >3Yr TBill</option>

<option value="3" >COFI</option>

<option value="4" >LIBOR</option>

<option value="5" >Other</option>

</select>
</td>

I've tried

[ 18. October 2003, 19:03: Message edited by: jacks73 ]

Top
#105532 - 2003-10-18 07:11 PM Re: Is it possible to update a web page with a KiXtart script?
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Yuck, get rid of the GOTOs in your code! Thery are unnecessary as they can be replaced by using DO-WHILE and LOOP-UNTIL constructs!
_________________________
There are two types of vessels, submarines and targets.

Top
#105533 - 2003-10-18 07:16 PM Re: Is it possible to update a web page with a KiXtart script?
jacks73 Offline
Getting the hang of it

Registered: 2003-04-23
Posts: 58
OOPS!
Never mind I just forgot some quotes

code:
$IE.Document.getelementbyid("4006index").value = $val  

Sorry

Top
#105534 - 2003-10-18 07:19 PM Re: Is it possible to update a web page with a KiXtart script?
jacks73 Offline
Getting the hang of it

Registered: 2003-04-23
Posts: 58
Jens,
Sorry about the goto's
I'll post without them when I get everything worked out.

Top
#105535 - 2003-10-23 04:27 AM Re: Is it possible to update a web page with a KiXtart script?
jacks73 Offline
Getting the hang of it

Registered: 2003-04-23
Posts: 58
Hello everyone,
Thank you all for your help in posts past.
I've just about got my script finished, but I've run into a bit of a snag. While I am able to login into the first page, and then I can enter the necessary information on the next page, I can not get the second page to save said info.

Here's my code

code:
 ;Set User Id and Password
$ID = 'name'

$PW = 'pwd'
$cnrfm7 ='z'

while $cnfrm7 = 'z'
;Get Values for to update on the fixed rate page
do
?'Enter 30 Year Fixed Conforming Rate>' gets $rte44
until $rte44
do
?'Enter 30 Year Fixed Conforming Points>' gets $pts44
until $pts44
do
?'Enter 30 Year Fixed Conforming APR (Enter X to auto calculate) >' gets $apr44
until $apr44
do
?'Enter 30 Year Fixed Conforming lock>' gets $lck44
until $lck44
; Format the numeric values to 3 decimal places. For the 'apr' variables
; this will change an 'x' entry to null for auto calculation by the webpage
if $apr44 = 'x'
$apr44 = ''
else
$apr44=formatnumber($apr44,3)
endif

$rte44=formatnumber($rte44,3)
$pts44=formatnumber($pts44,3)


do
?'You have entered:'
?' 30 Year Fixed Conforming Rate = $rte44'
?' 30 Year Fixed Conforming Points = $pts44'
?' 30 Year Fixed Conforming APR = $apr44'
?' 30 Year Fixed Conforming Lock = $lck44'
?'Are these values correct? (Y/N) >' gets $cnfrm7
until $cnfrm7
;Loop until either a "y" or a "n" is entered
while $cnfrm7 <> 'Y' and $cnfrm7 <> 'N'
do
?'Please enter Y or N>' gets $cnfrm7
until $cnfrm7
loop
loop


$URL = "https://www.the_site.com/script/lb_login.asp"

$IE = CreateObject("InternetExplorer.Application")

$IE.Visible = 1

$IE.Navigate($URL)

sleep 1
sendkeys('y') ;clears the certificate warning popup window

While $IE.Busy and $IE.ReadyState <> 4 and @ERROR = 0 Loop

$IE.Document.getelementbyid("custid").Value = $ID
$IE.Document.getelementbyid("pw").Value = $PW

$IE.Document.lblogin.posting.value = 1
$IE.Document.lblogin.Submit()

;Enters the loan information to each applicable field on the fixedrates.asp page

$IE.Document.getelementbyid("4004rate").Value = "$rte44"
$IE.Document.getelementbyid("4004points").Value = "$pts44"
;$IE.Document.getelementbyid("4004apr").Value = "$apr44"
$IE.Document.getelementbyid("4004lock").Value = "$lck44"

$date = @date


while @date = $date
sleep 900
; Saves the updated values for the happy.asp page

;This is the part that isn't working

$IE.document.fixrates.posting.value = 1
$IE.document.fixrates.submit()
loop

here' the HTML from the first page (the one I can get to work
code:
 <script>
<!--
function login_onclick()
{
// Validations
if ( isNaN(document.lblogin.custid.value))
{
alert( "Please enter a valid ID" );
document.lblogin.custid.focus();
return;
}

if ( document.lblogin.custid.value=="" )
{
alert( "Please enter ID" );
document.lblogin.custid.focus();
return;
}
if ( document.lblogin.pw.value=="" )
{
alert( "Please enter Password" );
document.lblogin.pw.focus();
return;
}
// all is well
document.lblogin.posting.value = 1
document.lblogin.submit();
return;
}
//-->
</script>

here's the HTML of the page that's not working
code:
 <script>
<!--
function save_onclick()
{
// NOTE: many lines commented out are a stub for the
// allowance of negative points in the future.
var numvals="0123456789.";
//var tempnumvals = numvals;
var dcnt;
//var negs;
var temp;
var e;
var i,j,k;
var ispoints = false;

// Validations - make sure all inputs are numeric
for ( i=0; i < document.fixrates.length ; i++ )
{
dcnt = 0;
negs = 0;
e = document.fixrates.elements[i];
if ( e.type == "text" )
{
// if field is points add "-" as a valid value
/*if (e.name.match("points"))
{
numvals += "-";
ispoints = true;
} */

for ( j=0; j < e.value.length; j++)
{
temp=e.value.substring(j,j+1)
if ( temp == "." ) dcnt++;

/*if (ispoints == true)
{
if ( temp == "-" )
{
negs ++;

if (e.value.indexOf(temp) > 0)
{
alert ("Please enter a valid number." );
field.focus();
return;
}
}

} */
//if ( ( numvals.indexOf(temp)==-1) || ( dcnt > 1 ) || ( negs > 1) )
if ( ( numvals.indexOf(temp)==-1) || ( dcnt > 1 ))
{
alert( "Please enter a valid number." )
e.focus();
return;
}
}

if ( isNaN( parseFloat( e.value ) ) )
{
alert( "Please enter a valid number." );
e.focus();
return;
}
// ispoints and okay value - revert numvals to prior state
//numvals = tempnumvals;
}
}
//This, jacks73 has determined, is the part I need help on

document.fixrates.posting.value = 1;
for (x=5; x<document.fixrates.length -4; x=x+ 7)
{

document.fixrates.elements[x].disabled=false;
}
document.fixrates.submit();
return;
}

How do I pass the "extra parameters" from the script?
Again all help is appreciated

Thanks,
J

[ 23. October 2003, 04:34: Message edited by: jacks73 ]

Top
#105536 - 2003-10-23 04:39 AM Re: Is it possible to update a web page with a KiXtart script?
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
What information does this yield:

$IE.document.fixrates.posting.value = 1

?"ERROR @ERROR : @SERROR"

$IE.document.fixrates.submit()

?"ERROR @ERROR : @SERROR"

-Shawn

Top
#105537 - 2003-10-23 04:45 AM Re: Is it possible to update a web page with a KiXtart script?
jacks73 Offline
Getting the hang of it

Registered: 2003-04-23
Posts: 58
Both

0, The operation has completed successfully

but the page doesn't save my new info

Top
#105538 - 2003-10-23 04:49 AM Re: Is it possible to update a web page with a KiXtart script?
jacks73 Offline
Getting the hang of it

Registered: 2003-04-23
Posts: 58
I have also tried;

$IE.document.fixrates.posting.value = 1
$IE.document.fixrates.elements(x).disabled=0
$IE.document.fixrates.submit()

With the same results for all three.

BTW good morning

Top
#105539 - 2003-10-23 04:53 AM Re: Is it possible to update a web page with a KiXtart script?
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
I would imagine that this second code snippet (save_click) is attached to a SAVE button on the second form ? Could you not just fill in the data, then attach to the save button in script, then invoke its click method which would then invoke this entire event for you ... ?
Top
#105540 - 2003-10-23 05:01 AM Re: Is it possible to update a web page with a KiXtart script?
jacks73 Offline
Getting the hang of it

Registered: 2003-04-23
Posts: 58
Shawn my friend,
75% of the KiXtart/HTML interaction I have learned from you. I suppose your suggestion could be done but how...?

I don't necessarily wan't a silver platter but a sense of direction would be awesome.

Top
#105541 - 2003-10-23 05:08 AM Re: Is it possible to update a web page with a KiXtart script?
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
I kinda hard to give clues or even hints when one can't see or run the code. Is there anyway to see the HTML for the second page ? Is this site accessable from the internet ?
Top
#105542 - 2003-10-23 05:22 AM Re: Is it possible to update a web page with a KiXtart script?
jacks73 Offline
Getting the hang of it

Registered: 2003-04-23
Posts: 58
It's a secure site. If I could let you in I would. However, when the "save" button is hovered, save_onclick (the name of the HTML function posted) is shown in the status bar of IE

[ 23. October 2003, 05:24: Message edited by: jacks73 ]

Top
#105543 - 2003-10-23 05:40 AM Re: Is it possible to update a web page with a KiXtart script?
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
I would just hunt and peck though the HTML in this second page and look for the ID or NAME of that save button, and simply do more of what you've already done:

$IE.Document.lblogin("javascript:login").click()

-Shawn

Top
#105544 - 2003-10-23 06:16 AM Re: Is it possible to update a web page with a KiXtart script?
jacks73 Offline
Getting the hang of it

Registered: 2003-04-23
Posts: 58
Tried
code:
 ; Saves the updated values for the fixedrates.asp page
$IE.document.fixrates.posting.value = 1
? @error @serror
$IE.document.fixrates("javascript:save_onclick").click()
? @error @serror

With the same results

Top
Page 2 of 3 <123>


Moderator:  Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1574 anonymous users online.
Newest Members
BeeEm, min_seow, Audio, Hoschi, Comet
17882 Registered Users

Generated in 0.21 seconds in which 0.165 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org