• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 582
  • Last Modified:

convert VB to javascript

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
red_75116
Asked:
red_75116
  • 3
  • 3
2 Solutions
 
leakim971PluritechnicianCommented:
<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
 
red_75116Author Commented:
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
 
leakim971PluritechnicianCommented:
it should work on all
do you have a link to see your page?
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
red_75116Author Commented:
it works fine in IE, but flashes the page, but doesnt open the link in Chrome.  Haven't downloaded FF yet to try.
0
 
leakim971PluritechnicianCommented:
let me see that in live

unactive your popup blocker
0
 
red_75116Author Commented:
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
 
hieloCommented:
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

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now