Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

convert VB to javascript

Posted on 2011-09-15
7
557 Views
Last Modified: 2012-05-12
Is it possible to convert this VB script to javascript?  This code works behind a button on a .net application.

Just wanted to see if javascript might make it more browser compliant
<table id="tblReqField" class="Form"> <tr class="SectionHeader"><TH>Actions</TH></TR></TABLE>

<button class="exButton" language="VBS" onclick="DoSomething()">Schedule appointment</button>

<script language="VBS">

Sub DoSomething()

   window.location = "WflRequest.aspx?CopyFields=1;2;30;31;91;&BCAction=0&Type=6011&CopyFrom=" & frmMain.RequestID.Value

End Sub

</script>

Open in new window

0
Comment
Question by:red_75116
  • 3
  • 3
7 Comments
 
LVL 82

Assisted Solution

by:leakim971
leakim971 earned 250 total points
ID: 36546450
<table id="tblReqField" class="Form"> <tr class="SectionHeader"><TH>Actions</TH></TR></TABLE>

<button class="exButton" onclick="DoSomething()">Schedule appointment</button>

<script language="javascript" type="text/javascript">

function DoSomething() {
   window.location.href = "WflRequest.aspx?CopyFields=1;2;30;31;91;&BCAction=0&Type=6011&CopyFrom=" + document.getElementsByName("RequestID")[0].value;
}

</script>

Open in new window

0
 

Author Comment

by:red_75116
ID: 36546542
thanks!  that works, but I was hoping to get this to work in chrome and possibly firefox but it doesn'.  Any ideas how to make work in other browsers??
0
 
LVL 82

Expert Comment

by:leakim971
ID: 36546568
it should work on all
do you have a link to see your page?
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

Author Comment

by:red_75116
ID: 36546585
it works fine in IE, but flashes the page, but doesnt open the link in Chrome.  Haven't downloaded FF yet to try.
0
 
LVL 82

Expert Comment

by:leakim971
ID: 36546604
let me see that in live

unactive your popup blocker
0
 

Author Comment

by:red_75116
ID: 36546610
it could be my app not your code

found this error in chrome
Failed to load resource: the server responded with a status of 400 (Bad Request)

0
 
LVL 82

Accepted Solution

by:
hielo earned 250 total points
ID: 36547235
try:
<script type="text/javascript">

function DoSomething()
{
   window.location.href = "WflRequest.aspx?CopyFields=1;2;30;31;91;&BCAction=0&Type=6011&CopyFrom=" + document.frmMain.RequestID.value;

}

</script>


NOTE: Unlike VBScript, Javascript IS case sensitive. Thus, due to:
document.frmMain.RequestID.value;

your HTML should have:
<form name="frmMain"...>

but NOT <form name="FrmMain"...> (notice the capital "F").  To javascript, frmMain and FrmMain are different.

The same goes for the other input - you should have:
<input name="RequestID" ...>

IF your markup is different, then adjust the javascript line accordingly - in other words, if you have:

<form name="FRMMain"...>
<input name="requestID" ...>

then you should use this instead:
document.FRMMain.requestID.value;

Open in new window

0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question