Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Combine strings and text, to create url for load function Reply To: Combine strings and text, to create url for load function

#153500
bcintegrity1
Participant

First and foremost, thank you both Mottie and vindicateme for your time and effort!!! I finally got it to work with your help:) Here is the working code:

$('.proviewtab').click(function(e){  
     var name = $(this).closest(".pro").find("p").text();
     name = name.split(/^(\w+)\s+(\w+)/);
     var firstName = name[1]; 
     var lastName = name[2];
     var folder = "reviews-pest-control-va";  
     var reviewsPath = folder + '/' + lastName + ',' + firstName + '.php';
     reviewsFile = reviewsPath.toLowerCase();
        e.preventDefault();
        $('#insert').empty();
        $('#insert').load(reviewsFile);
        $('.lbox').removeClass('hbox');
        $('.lbox').addClass('tempbox');
        $('.mainflipper').addClass('top');
   });

For some reason, match didn’t work…but the regex did. I eliminated the each function by using the closest method. And I changed the p2 to p, styling it using li.services p{} instead of p2.

Again, THANK YOU!