473,574 Members | 2,474 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need to output "String id" as "Numeric value" in different places using a loop

Could anyone please help me with the following problem

My xml file is
==============
<fig id="F0000001">
<caption>Captio n text</caption>
<image id="I0000001" image.class="ha lftone" image.type="jpg " print="0"
width="29-6" depth="23-6" pointer="I00000 01.jpg"/>
</fig>

I need my output in IE Browser using Javascript as follows (need it in
a loop, as I need to print in different places)

fig id output
======== ========
F0000001 1
F0000021 21
S0000001 1
S0000021 21

Mar 31 '06 #1
2 1466
ja*****@rediffm ail.com wrote:
Could anyone please help me with the following problem

My xml file is
==============
<fig id="F0000001">
<caption>Captio n text</caption>
<image id="I0000001" image.class="ha lftone" image.type="jpg " print="0"
width="29-6" depth="23-6" pointer="I00000 01.jpg"/>
</fig>

I need my output in IE Browser using Javascript as follows (need it in
a loop, as I need to print in different places)

fig id output
======== ========
F0000001 1
F0000021 21
S0000001 1
S0000021 21


To converting the string a primitive number assuming the format above:

var stringID = 'I00301';
var numberID = stringID.replac e(/^\D*0*/,''); // --> 301
That will remove any leading non-digits and zeros in any browser that
supports regular expressions (which includes IE).

--
Rob
Mar 31 '06 #2
JRS: In article <442d2c51$0$214 2$5a62ac22@per-qv1-newsreader-
01.iinet.net.au >, dated Fri, 31 Mar 2006 23:17:55 remote, seen in
news:comp.lang. javascript, RobG <rg***@iinet.ne t.au> posted :
To converting the string a primitive number assuming the format above:

var stringID = 'I00301';
var numberID = stringID.replac e(/^\D*0*/,''); // --> 301
That will remove any leading non-digits and zeros in any browser that
supports regular expressions (which includes IE).


And will remove the whole of "F0000000".
Maybe stringID.replac e(/^\D*0*(.)/, '$1'); to be safer?

--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.c om/faq/> JL/RC: FAQ of news:comp.lang. javascript
<URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Apr 1 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
6493
by: Russ Perry Jr | last post by:
I'm using "ID" and "Value" in the generic sense here... Let's say one page I had a <html:select> with a collection like this: <html:options collection="items" property="key" labelProperty="value"/> In this case "key" is what I mean by "ID", and "value" is what I mean by "Value" -- the "Value" is shown to the user, but the "ID" is what I...
7
3662
by: ma740988 | last post by:
The string object value_f doesn't produce the right output. At issue, - I suspect - is the conversion from string to int with istringstream. An alternate approach? Thanks in advance #include <iostream> #include <sstream> #include <string> using namespace std;
5
17681
by: johnsuth | last post by:
I want to produce a trivial demonstration of dynamic modification. I thought that pressing a button might change its color. I studied O'Reillys books and successfully created the button with a fancy style, but the onclick fails to do anything no matter what permutation of parameters I try. <input type=button...
28
5268
by: Andre | last post by:
Hi, Does anyone know whether the ECMA, or an other standard document, specifies a maximum for the value that can be pass to the setTimeOut() function in Javascript? Andre
4
4877
by: chaz | last post by:
here is the html : <br> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="<%=LABEL_WIDTH%>" class="formtext"><%= HTEXT("Connection type:")%></td> <td class="formtext"> <input type="radio" class="inputRadio" id="dbStatus" name="dbStatus" value="1" onclick="changeDbStatus(1)" <%if dbStatus=1 then%checked
3
5020
by: Ady1 | last post by:
Hi, I'm getting this error intermitantly in a custom configuration section in my ASP.NET website. From what I can see 0.175 is a valid string to be converted to a decimal! And most of the time it works, so why is it that about once a week for about half an hour I get this error? Any Ideas? Thanks, Ady
1
1718
by: carl34 | last post by:
Hi Can someone tell me why am i getting this error? Cast from string "" to type 'Long' is not valid. Location: at Microsoft.VisualBasic.CompilerServices.LongType.FromString(String Value) at ItemExchange.WorkerX9Process.CreateAdministrativeReturnReport(CJOB& objJob, CExchangeItemDatas& objExchangeItemDatas, CDelimitedExportFile&...
1
14024
by: ChollaPete | last post by:
This code: <form action="processScan.php" method="get"> <p> <?php print "Scan name: <input type=\"file\" name=\"tScanFileName\" value= \"{$scanFileName}\"><br>"; addHiddenCarryons(); ?> <input type="submit">
7
4430
vikas251074
by: vikas251074 | last post by:
I am getting error above in following code since few days giving tension day and night. How can I solve this? I am facing since Oct.25. in line no. 362 After doing a lot of homework, I am surrendered to you. <%@ Language=VBScript%> <%Option Explicit%>
0
7803
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8044
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7810
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8096
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6451
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5299
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3739
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2240
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1337
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.