473,386 Members | 1,621 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

simulating/calling javascript functions programmatically

YR
Hello,

I am tasked to write an application for a travel agency, that should be able to get a price for airline tickets from airline's website. Generally, airlines don't provide any web services for this, so I am sort of forced to simulate all the clicks/list boxes selection that a regular user would make. Most of those buttons have a java script associated with them, so as soon as a button's clicked -- java script runs.

So, here is the question: what's the best way to implement a call to a javascript? Would I use ASP.NET platform, since it has these HttpRequest / Response objects? What would I put in my HttpRequest?

For instance, if a web page http://www.mysite.com/page.cgi has a java script that looks something like this:

function submit_SomeForm()
{
document.SomeForm.A.value = "A"
document.SomeForm.B.value = "B"
document.SomeForm.C.value = "C"

document.SomeForm.submit()
}

What would be a code snippet that would setup SomeForm document with all the values and submit it to the site?
Also, what tools would I use to see what the http string that goes from my browser to the site is like?

I understand that I am sort of asking for a lot but I appreciate any help -- I am a rookie at this and it's tough to ask the right question :)

I appreciate any help.

Sincerely,
YR
Nov 18 '05 #1
5 3101
Take a look at the WebRequest class which will allow you to do GET and
POST. For example, here is a sample doing a POST :
http://samples.gotdotnet.com/quickst...lientPOST.aspx

One of the first tools I would get for debugging would be something
like tcpTrace (see http://www.pocketsoap.com/tcptrace/). This easily
allows you to see all the traffic between yourself and a web site. You
can compare what your code is sending versus what the browser sends.
Even before debugging, it will show you a little bit about what
happens on the form.submit call.

HTH,

--
Scott
http://www.OdeToCode.com

On Wed, 21 Jan 2004 22:56:06 -0800, "YR"
<an*******@discussions.microsoft.com> wrote:
Hello,

I am tasked to write an application for a travel agency, that should be able to get a price for airline tickets from airline's website. Generally, airlines don't provide any web services for this, so I am sort of forced to simulate all the clicks/list boxes selection that a regular user would make. Most of those buttons have a java script associated with them, so as soon as a button's clicked -- java script runs.

So, here is the question: what's the best way to implement a call to a javascript? Would I use ASP.NET platform, since it has these HttpRequest / Response objects? What would I put in my HttpRequest?

For instance, if a web page http://www.mysite.com/page.cgi has a java script that looks something like this:

function submit_SomeForm()
{
document.SomeForm.A.value = "A"
document.SomeForm.B.value = "B"
document.SomeForm.C.value = "C"

document.SomeForm.submit()
}

What would be a code snippet that would setup SomeForm document with all the values and submit it to the site?
Also, what tools would I use to see what the http string that goes from my browser to the site is like?

I understand that I am sort of asking for a lot but I appreciate any help -- I am a rookie at this and it's tough to ask the right question :)

I appreciate any help.

Sincerely,
YR


Nov 18 '05 #2
Take a look at the WebRequest class which will allow you to do GET and
POST. For example, here is a sample doing a POST :
http://samples.gotdotnet.com/quickst...lientPOST.aspx

One of the first tools I would get for debugging would be something
like tcpTrace (see http://www.pocketsoap.com/tcptrace/). This easily
allows you to see all the traffic between yourself and a web site. You
can compare what your code is sending versus what the browser sends.
Even before debugging, it will show you a little bit about what
happens on the form.submit call.

HTH,

--
Scott
http://www.OdeToCode.com

On Wed, 21 Jan 2004 22:56:06 -0800, "YR"
<an*******@discussions.microsoft.com> wrote:
Hello,

I am tasked to write an application for a travel agency, that should be able to get a price for airline tickets from airline's website. Generally, airlines don't provide any web services for this, so I am sort of forced to simulate all the clicks/list boxes selection that a regular user would make. Most of those buttons have a java script associated with them, so as soon as a button's clicked -- java script runs.

So, here is the question: what's the best way to implement a call to a javascript? Would I use ASP.NET platform, since it has these HttpRequest / Response objects? What would I put in my HttpRequest?

For instance, if a web page http://www.mysite.com/page.cgi has a java script that looks something like this:

function submit_SomeForm()
{
document.SomeForm.A.value = "A"
document.SomeForm.B.value = "B"
document.SomeForm.C.value = "C"

document.SomeForm.submit()
}

What would be a code snippet that would setup SomeForm document with all the values and submit it to the site?
Also, what tools would I use to see what the http string that goes from my browser to the site is like?

I understand that I am sort of asking for a lot but I appreciate any help -- I am a rookie at this and it's tough to ask the right question :)

I appreciate any help.

Sincerely,
YR


Nov 18 '05 #3
I had a similar query (actually posted it just before yours) and found my
answer in the Page.RegisterClientScriptBlock method. It lets you add client
side Javascript to your page from within your server side ASP.NET code.

Regards,

Lachlan
Nov 18 '05 #4
YR
Thanks.

YR
Nov 18 '05 #5
YR
Thanks.

YR
Nov 18 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Dave Ekhaus | last post by:
hi i'd like to call a python function programmatically - when all i have is the functions name as a string. i.e. fnames = for func in fnames:
7
by: Julia Briggs | last post by:
Hello World - I admit I'm new to javascript but I've tried for days to find a solution to my problem. Basically I have 3 unique javascript files that do different screen display events that I...
7
by: JCO | last post by:
I have several JavaScripts in a web page. Each script is in an individual file with extension .js. I want to know if it is possible to put all functions in one single page. If so, how do I call...
21
by: ryanmhuc | last post by:
I know the subject might be confusing. I am no beginner with javascript but I haven't been able to figure out how to get the javascript file name from code inside the file. So you have an HTML...
1
by: Chris | last post by:
Hi. I have a ibrary I'm trying to use via javascript within IE. This library uses an asynchronous model where I call into a function and pass it a callback function as one of its arguments. My...
4
by: Roger Withnell | last post by:
I would like to freeze column and row headings on a webpage, simulating freeze panes as in an Excel spreadsheet. Don't seem to be able to do it with Frames. Is there a way with Javascript...
1
by: Tom Cole | last post by:
I've written a small javascript library to help automate Ajax requests and the like. One of the things I want the library to do is display a "Please wait" indicator in the upper right hand corner...
4
by: r_ahimsa_m | last post by:
Hello, I am learning WWW technologies in Linux. I created index.html file which I can browse with Firefox/Konqueror using URL localhost/~robert/rozgloszenia/index.html. The page looks fine but...
5
by: Xu, Qian | last post by:
Hello All, I have some problem by simulating a link click using javascript. The webpage uses a js-library named interface (jQuery like) ------------------------------ <a id="foo" href="#">Try...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.