Solved

Problems pulling in Javascript Form Variables containing a ForwardSlash (/)

Posted on 2007-11-15
5
763 Views
Last Modified: 2013-11-19
I have a Javascript function that pulls in a couple of variables from a form, it works fine until it tries to pull in a variable that contains a forwardslash ( / ), then it just cuts off the field at the slash.

The function looks like this:

function runJob() {

  var shell = new ActiveXObject("WScript.shell");
  shell.run("S:/function.bat "+frmTable.Item.value+" "+frmTable.Serial.value);
}

So, for the Serial value, it will pull in a field of 12345 just fine, but a field of 12345/6789 will cut off at the /

For clarification here is the variable as declared in the table

<td align="right">~{sSerialNumber}:</td>
<td align="left"><input type="text" name="Serial" size="12" maxlength="30" onfocus="this.scrollIntoView(false)"/></td>

Any ideas?
0
Comment
Question by:deltex141
  • 2
  • 2
5 Comments
 
LVL 21

Accepted Solution

by:
nizsmo earned 500 total points
ID: 20290993
Try modify your function to this and see if it works.
function runJob() {

  var serialValue = frmTable.Serial.value;

  serialValue = serialValue.replace("/","\/");

  var shell = new ActiveXObject("WScript.shell");

  shell.run("S:/function.bat "+frmTable.Item.value+" "+serialValue);

}

Open in new window

0
 
LVL 4

Author Comment

by:deltex141
ID: 20291130
function runJob() {
  var serialValue = frmTable.Serial.value;
  serialValue = serialValue.replace("/","\/");
  var shell = new ActiveXObject("WScript.shell");
  shell.run("S:/function.bat "+frmTable.Item.value+" "+serialValue);
}

What is the / going to be replaced with? We still need the slash to be pulled in, not just replaced or removed
0
 
LVL 3

Expert Comment

by:kylealanhale
ID: 20291285
It'll be replaced with an escaped slash  It should work perfectly.
0
 
LVL 21

Expert Comment

by:nizsmo
ID: 20291781
yes as kylealanhale said, it will escape the "/" as it is conflicting with your code. Don't worry, the / won't get deleted or removed.

hope this helps.
0
 
LVL 4

Author Closing Comment

by:deltex141
ID: 31409378
That worked great, Thanks!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

920 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now