473,609 Members | 1,851 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 1471
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
6496
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 plan to keep, to be saved to a database (as a reference in a table to a common table as a part of...
7
3665
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
17684
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 style=background-color:yellow;color:blue;font-family:Arial;font-style:italic;font-weight:bold name="xyz" value="CHANGE COLOUR"...
28
5272
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
5023
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& objAdministrativeReturnReport, ExportFileTypeEnum enmReportType Kind regards, Carl
1
14026
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
4432
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
8139
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8579
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8555
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8232
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
7024
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6064
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5524
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4098
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1686
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.