Wrox Programmer Forums
|
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 28th, 2006, 02:00 PM
Registered User
 
Join Date: Nov 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Parse String Issues

Hello,
I have a form that contains data in a read-only, tab delimited, format. The element name is BankAddAccess.Role1. I am having troubles extracting each value into an array of values, here is the code I am using:

var exOption, exDictionary, exResult, fieldVal, testVal;
exDictionary = document.all['BankAddAccess.Role1'];
fieldVal = exDictionary.value;
    while((exResult = fieldVal.split(/\t,\r/)) != null) {
        alert(exResult[0]);
        break;
        }


The array ends up with the full string as the first value. Is there something I'm missing here? Thank you for any help you can provide.

 
Old January 15th, 2007, 05:10 PM
Registered User
 
Join Date: Nov 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I could really use some help with this. Does anyone have any ideas? I'm sure there is something I have overlooked. Thanks again.

 
Old January 18th, 2007, 05:29 AM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919
Default

Hii jafuller!!


Data is tab delimited--> I used \t
<script>


var exOption, exDictionary, exResult, fieldVal, testVal;
exDictionary = document.all['BankAddAccess.Role1'];
fieldVal = exDictionary.value;

//e.g--> fieldVal = "11 1 2 3 4"


regExp=/\t/g

exResult=fieldVal.split(regExp);

 for(i=0;i<exResult.length;i++)
 {
 alert(exResult[i])
 }

 </script>
Hope this will help you


Cheers :)

vinod
 
Old January 18th, 2007, 04:01 PM
Registered User
 
Join Date: Nov 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

That did it. Thanks for the help vinod!






Similar Threads
Thread Thread Starter Forum Replies Last Post
connection string issues, web.config file issues kaliaparijat ASP.NET 2.0 Professional 1 June 12th, 2008 08:07 AM
Parse XML string parameter from XSLT maulik33 XSLT 6 December 5th, 2007 11:51 AM
PHP Parse error: parse error, unexpected T_STRING geminient PHP How-To 4 August 18th, 2007 02:27 AM
DataAdapter Connection string issues.... lochoa .NET Framework 2.0 0 January 30th, 2007 10:03 AM
C# String Performance Issues muzz C# 1 December 20th, 2005 11:39 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.