473,385 Members | 1,341 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,385 software developers and data experts.

How to call a vb script funtion in form load ??

Hi,

I am a new bi in asp...
I need to call a function in asp with vb script in form load...without button fire.

please give sample code...

Thanks and Regards,



Bijesh
Jan 27 '10 #1
6 9802
yarbrough40
320 100+
do you mean?

Expand|Select|Wrap|Line Numbers
  1. Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  2.  
  3. MyFunction()
  4.  
  5.     End Sub
  6.  
Jan 27 '10 #2
Hi,

Actually I have currency conversion coding from INR to USD .But it will execute in Button click only...ie we need to give the amount in INR in textbox.and while clicking submit button , it wil convert the amount into USD and will show the output.

Instead of button click event, I need to show the output while the page loaded. I set the input as static(ie textbox value I set to some value).so by taking that input it will execute and show the corresponding amount in USD.


The following is the code....I need to call a function for this conversion...



<%@ language="VBScript" %>

<html>
<head>
<title>Currency Server ASP Example 2</title>
</head>

<body>
<!-- declare application object -->
<%
Const curncsrvReturnRateString = 1
Const curncsrvReturnRateNumber = 2
Dim objApplication, objCurrencies,URL


Set objApplication =Server.CreateObject("CurrencyServer.Application")
Set objCurrencies = objApplication.ActiveCurrencies


%>
&nbsp;






<table border=0>


<td style="visibility:hidden" ><%= objCurrencies.Count %></td></tr></table><br>

<!-- currency conversion form -->
<form onload=csexample2.asp method="POST">


<table>
<tr>
<td> </td>
<td><select name=CurrFrom style="HEIGHT: 22px; WIDTH: 166px;visibility:hidden; ">
<% For i = 1 To objCurrencies.Count
if Request.Form("CurrFrom") = "INR" then %>
<option selected><%="INR"%>
<% else %>
<option><%="INR"%>
<% end if%>
<% Next %>
</select>



</td>
<td> </td>
<td><select name=CurrTo style="HEIGHT: 22px; WIDTH: 166px;visibility:hidden;">
<% For i = 1 To objCurrencies.Count
if Request.Form("CurrTo") = "USD" then %>
<option selected><%= "USD"%>
<% else %>
<option><%= "USD"%>
<% end if%>
<% Next %>

</select></td>
</tr>
<tr>
<td>Amount to convert:</td>
<td>
<input name=FromValue value="100">


</td>
<td></td>
<td></td>
</tr>
<tr>
<td>
<input type="submit" name="Convert" value=Convert>
</td>
<td>
</td>
<td></td>
<td></td>
</tr>
<tr>
</tr>
<tr>


<% dim ToValue %>
<% dim FromValue %>
<% FromValue=Request.Form("FromValue") %>

<!-- validation of input data -->
<% if (FromValue > "") and (IsNumeric(FromValue)) then
ToValue = objApplication.Convert(Request.Form("CurrFrom"), Request.Form("CurrTo"), Request.Form("FromValue"), true, ". ", curncsrvReturnRateString)
end if %>
<!-- empty -->
<% if FromValue = "" then ToValue = "" end if %>
<!-- alpha -->
<% if not IsNumeric(FromValue) then
FromValue = ""
ToValue = ""
end if
%>
<td>Result:</td><td><input name=ToValue Value="<%=ToValue%>"></td>
<td></td>
<td></td>
<!-- free resources -->
<% Set objApplication = Nothing %>


</tr>
</table>
</form>
</body>
</html>
Jan 28 '10 #3
yarbrough40
320 100+
just give your function a name like "MyFunction" then I believe you can call it using something like:

onLoad=”MyFunction()”
Jan 28 '10 #4
Hi,

If I need to call this in form load or page load???

Please give a sample code...How to call?

How the function look like??

Thanks and Regards
Bijesh
Jan 29 '10 #5
yarbrough40
320 100+
I'm a .net programmer so I apologize if I can't be of further assistance. but it would seem to me that you could build a function (use 'sub') and then type "call" to call it. place the code within the body of the page. the sub procedure will run when the page loads.

Expand|Select|Wrap|Line Numbers
  1.         <script type="text/vbscript">
  2.  
  3. sub MySub()
  4. dim i
  5. i = 0
  6. End Sub
  7.  
  8. call MySub()
  9.  
  10. </script>
  11.  
Jan 29 '10 #6
jhardman
3,406 Expert 2GB
OK, I need to clarify, and I'm not sure I follow your explanation of the problem.
1- Are you trying to run client-side VBScript? Although it is technically possible, I think only Internet Explorer ever supported that, and it was only standard in pre-IE7. Most people use Javascript to execute code on the browser. Nevertheless, if that is what you are trying to do, I can try to help you.
2- Are you trying to call an ASP function after the page is sent to the client? That will not work, the ASP script is completely finished by the time it is sent to the browser. Calling an ASP function after the browser receives the page is like trying to get a factory option installed on your car AFTER you receive it. If you want the function to execute while the form is being BUILT, that is another question.

Jared
Jan 29 '10 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: Carramba | last post by:
hi! I don't have eny code to chare, this is just teoretical question. usualy you have for looks like <form method="POST" action="some_php_script.php"> namn: <input type="text" name="name"...
0
by: Tom | last post by:
delphi 7 python 2.3 win98 Python for Delphi V3.25 In Delphi: 1 Create a new Form ; 2 Drop a TMemo(Memo1) to contain python code; 3 Drop a TPythonInputOutput (PythonInputOutput1) ;
3
by: JoeK | last post by:
Hey all, I am automating a web page from Visual Foxpro. I can control all the textboxes, radio buttons, and command buttons using syntax such as: ...
7
by: priya.tweety | last post by:
How to call a js file from another js file?
7
by: C.Joseph Drayton | last post by:
I have a problem that I am hoping someone can help me with. First let me describe the problem. I have an HTML form that in one field has an onBlur call to a JavaScript function. When you exit the...
7
by: Wladimir Borsov | last post by:
I want to call a perl script myscript.pl in my cgi-bin from a HTML web page. This call should NOT use SSI (because in this case HTTPS://.... protocol is necessary). Furthermore NO button click...
11
by: yangsuli | last post by:
i want to creat a link when somebody click the link the php script calls a function,then display itself :) i have tried <a href=<? funtion(); echo=$_server ?>text</a> but it will call the...
10
by: IchBin | last post by:
I am trying to set the state of a radio button. I do not see what I am doing wrong. Sorry, I am new at this.. I need another set of eyes to look at this snip of code. I am trying to set the radio...
4
by: faraz | last post by:
I have a javascript function that i want to call masterpage load method called. I cant add onLoad event of body or table in master page. I have put the call to script function in <form>, it...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...

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.