Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Remove part of url

Posted on 2013-01-13
2
Medium Priority
?
377 Views
Last Modified: 2013-01-13
Hi,

I'm trying to remove the last part of an url, when a dropdown is changed, that looks like this:
edit.php?do=delete&id=x
The "X" needs to be replaced.

The code is use is:
$('#delemail').attr('href', function(index, attr) {
	var url1 = attr;
	url = url1.substring(0, url1.length - 1);
	return url + foo;
});

Open in new window


But this only removes the 'X'. So the first time it works fine, but if the "X" is replaced with an id, like 233, and the dropdown is changed again, the id will be: 23XXX

How do i completely replace the whole id onchange? (no matter how long the id is)

Thanks
0
Comment
Question by:peps03
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 28

Accepted Solution

by:
rrz earned 1200 total points
ID: 38772126
If  id is always the last param, then you could use the String method    lastIndexOf().
url = url1.substring(0, url1.lastIndexOf("=") + 1);

Open in new window

0
 

Author Closing Comment

by:peps03
ID: 38772237
Thanks!!
0

Featured Post

Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn how to dynamically set the form action using jQuery.
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)
Suggested Courses

715 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