Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2007-11-15
5
Medium Priority
?
778 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 2000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Suggested Courses

824 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