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
October 19, 2013 at 12:22 pm
#153500
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!