Solved

php explode alternative in jquery

Posted on 2009-05-20
6
3,388 Views
Last Modified: 2012-05-07
hi . i have a value in variable  like this price_33,product_1 . i want to explode like php function and store in array or two separate variables ..

simple javascript or jquery solution ?
0
Comment
Question by:hiddenpearls
  • 3
  • 3
6 Comments
 
LVL 42

Accepted Solution

by:
David S. earned 500 total points
ID: 24429611
0
 

Author Comment

by:hiddenpearls
ID: 24429738
thanks , it helped me !
0
 

Author Comment

by:hiddenpearls
ID: 24429915
hmm one problem .. still

$copy_image_product_price_id=$($id).attr("id");
                 
                              var exploded = copy_image_product_price_id.split(',');
                              var product_code=exploded[0];
                              var product_price=exploded[1];

i m getting id and then split it but it not works ..giving me error ..  
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 42

Expert Comment

by:David S.
ID: 24439358
"$copy_image_product_price_id" and "copy_image_product_price_id" are two different variable names. Make sure they match.
0
 

Author Comment

by:hiddenpearls
ID: 24439845
@Kravimir: yes , that was the problem . u right . but what is difference between them ?
are they same variables of javascript ?
 
0
 
LVL 42

Expert Comment

by:David S.
ID: 24440383
In PHP "$" indicates the start of a variable name, but in JavaScript it's just one of the characters allowed in variable names.  "myString" and "$myString" are different variable names just like "myString", "mystring", and "my_string" are all different.

I suggest you read this: https://developer.mozilla.org/en/Core_JavaScript_1.5_Guide/Variables
0

Featured Post

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

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

Suggested Solutions

How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
Introduction JSON is an acronym for JavaScript Object Notation.  It is a text-string data transport mechanism, capable of representing simple or complex data structures in a consistent and easy-to-read manner.  Similar in concept to XML, but more e…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

828 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