Link to home
Start Free TrialLog in
Avatar of Whing Dela Cruz
Whing Dela CruzFlag for Anguilla

asked on

VBScript on Html

Hi experts, How to write VBScript on Html?

<button onclick="myFVbscript()">Click me</button>

<vbscript>
Function myFVbscript()
{
<%
txt="This is a beautiful day!"
response.write(Mid(txt,1,1))
%>
}
</vbscript>
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

do you want to use client side vbscript or server side vbscript? for client side vbscript it probably only works in IE only.
Avatar of Whing Dela Cruz

ASKER

I want this to work at client side. Thanks!
you may try this but it may works in certain IE browsers:

<p id="msg">test</p>

<button onclick="myFVbscript()">Click me</button>

<script type="text/vbscript">
Function myFVbscript()
    txt="This is a beautiful day!"
    document.getElementById("msg").innerHTML = Mid(txt,1,1)
End Function

</script> 

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi Ryan, the code is running only in JavaScript. Is there any alternatives to achieve my goal?
since you want to run it at client side, you can do it via Javascript or Vbscript. both i posted a sample above.

do you need further assistance here? or what actually you intend to do?
Hi Ryan, you gave me right idea on this topic so I will close this right now since I have posted other question entitled, Asp in script. This question is exactly the same with this. I hope you will still participate. Thank you!
just wanted to add my .02 cents worth here, as I've seen some of your posts and you yourself told me you were new to ASP and wanted advice...

is there a specific reason why you want to use client side vbscript? I ask because, while you CAN technically do it, it is not common to do so with web pages. Also, it's not supported across browsers, especially older browsers, and most resources you'll find will be done in javascript. Unless you have a specific reason to use vbscript (I cant really think of one), I recommend always using javascript.
Hi Monty, The code below is the reason why I'm looking for a solution, VBScript. The code is running but have no option from the clients when to run it. So, I look for a command that I could use button before the data will download to the table. Is the code below has an equivalent to JavaScript? I'm hoping you can also help me settle this problem.    

<button onclick="myFirstTable()">Click me</button>
 
<%
   filePath = "C:\MyDb\DbUsers.accdb"

   Set objConn = Server.CreateObject("ADODB.Connection")
   objConn.Open ("Provider=Microsoft.ACE.OLEDB.12.0.1; Data Source=" & filePath & "; Persist Security Info=False; Jet OLEDB:Database Password=iErwin")
   Set rs = objConn.execute("Select UserCode, UserName, TelNumber, iPassword from MyUsers")    
   %>

   <table border=".25" width="50%" bgcolor="#fff5ee">
     <tr>
   <%for each x in rs.Fields
    response.write("<th align='left' bgcolor='green'>" & x.name & "</th>")
  next%>
  </tr>
   
   <%do until rs.EOF%>
     <tr>
     <%for each x in rs.Fields%>
       <td><%Response.Write(x.value)%></td>
     <%next
     rs.MoveNext%>
     </tr>
   <%loop

   rs.close
   objConn.close
   %>
The code is running but have no option from the clients when to run it

not sure what you mean here, are you saying your client doesn't have a place to host this page?
What I mean is that, the code will automatically download the data from the server during onloading. So the client has no option when to download the data. so, i need to use button with an event that the data will only appear at the that I press the button.
didn't another expert address this in another question you posed?
Hi Big Monty, I've been waiting for someone (Experts) to share their ideas/advice about this issues but nobody participates..
ok i thought you had asked exactly how to do this in another question, but going back and looking, I couldnt find it.

ya this Topic forum can be quiet, classic asp is not as popular as other technologies, so this forum is visited much :)

ask a question along the lines of "i want to load my data upon clicking a button and not upon page load. here is what I have" and post the code from above. If I get some time later, I'll pop in and help you, or I'm sure one of the other experts will chime in, as it's a pretty simple task
Okey Monty I will post it now...