Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2007-11-15
5
Medium Priority
?
776 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
[X]
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
  • 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

Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

Question has a verified solution.

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

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL several years ago, it seemed like now was a good time to update it for object-oriented PHP.  This article does that, replacing as much as possible the pr…
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

670 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