473,387 Members | 1,463 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Problem while Passing xml value into function

Hi,
JavaScript
Expand|Select|Wrap|Line Numbers
  1. ..
  2. var i=0;
  3. basechem="<UL>";
  4. while (i >= 0) {
  5.     basechem = xml.getElementsByTagName("basechemical")[i];
  6.  
  7.     basechem = basechem.firstChild.data; 
  8.     basehtml +=  "<LI><a href=# onClick=passChemicalName("+ i +")>" + basechem + "</a></LI>";
  9.  
Here instead of "i", i want to pass "basechem" but it wont work. why this happens, it take numeric value but cant take xml data.
when i got this xml value, then i want to pass this value into parent window (which is a child window of another window) text box.
please help.
Jul 20 '07 #1
3 1209
iam_clint
1,208 Expert 1GB
Expand|Select|Wrap|Line Numbers
  1.     basehtml +=  "<LI><a href=# onClick=passChemicalName('"+ basechem +"')>" + basechem + "</a></LI>";
  2.  
Hey there sorry I didn't answer this sooner just now seen the post but thats how you would do it by adding ' before and after '


(" + whatever + ") would look like this (whatever) which would assume numeric only.

but ('" + whatever + "') would look like this ('whatever') which is a string because of ' the quotes ' So now it will pass the information you want.
Jul 20 '07 #2
I had tried this by using ('"+whatever+"')
but IE giving me Unterminated string error.

Expand|Select|Wrap|Line Numbers
  1.     basehtml +=  "<LI><a href=# onClick=passChemicalName('"+ basechem +"')>" + basechem + "</a></LI>";
  2.  
Hey there sorry I didn't answer this sooner just now seen the post but thats how you would do it by adding ' before and after '


(" + whatever + ") would look like this (whatever) which would assume numeric only.

but ('" + whatever + "') would look like this ('whatever') which is a string because of ' the quotes ' So now it will pass the information you want.
Jul 20 '07 #3
iam_clint
1,208 Expert 1GB
well is there any " or ' in your string?
Jul 20 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

58
by: jr | last post by:
Sorry for this very dumb question, but I've clearly got a long way to go! Can someone please help me pass an array into a function. Here's a starting point. void TheMainFunc() { // Body of...
6
by: Olaf Martens | last post by:
Greetings! Please consider the following piece of program code (note that I have stripped quite a lot of code here): int foo(void) { unsigned short l_valbuf; // address of this goes to...
9
by: SB | last post by:
Ok, very simple problem. I'm trying to update a value by calling a function using pass by reference, but it does not update the value. In short, the value I'm trying to update is balance, which is...
15
by: Peter Afonin | last post by:
Hello, I'm struggling with the string conversion to MD5 which I've never user before. I have a string that I need to encode which looks approximately like this: ...
6
by: ged | last post by:
Hi, i am a oo (c#) programmer, and have not used javascript for a while and i cant work out how javascript manages its references. Object References work for simple stuff, but once i have an...
12
by: Andrew Bullock | last post by:
Hi, I have two classes, A and B, B takes an A as an argument in its constructor: A a1 = new A(); B b = new B(a1);
39
by: Martin Jørgensen | last post by:
Hi, I'm relatively new with C-programming and even though I've read about pointers and arrays many times, it's a topic that is a little confusing to me - at least at this moment: ---- 1)...
26
by: the.tarquin | last post by:
Okay, this one has me totally baffled. I have a function, getParsedKey(char* key, char* returnString). I pass in the key I want, it retrieves it from a data structure and puts the value in...
17
by: Ashwin | last post by:
hi guys, i have overloaded the << operator.as shown below. ostream& operator<<(ostream &out, const student &a) { out<<a.idno; out<< " " ; // out<< a.name; out<< " " ; // out<< a.marks...
11
by: venkatagmail | last post by:
I have problem understanding pass by value and pass by reference and want to how how they are or appear in the memory: I had to get my basics right again. I create an array and try all possible...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

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.