Solved

Issues with following javascript

Posted on 2013-06-13
3
235 Views
Last Modified: 2013-06-18
Hi, working on a custom Project, i had encountered jquery, altough all good and working fine, but it needs to be converted in basic javascript, so i am not too good in javascript, so Please guide me here what i am missing

Jquery Code:

[u]This i have changed [/u]
 [b]onclick="removetext(this.parentNode);"[/b]
[u]before it was like below [/u]
[b] onclick="removetext($(this).parent());"[/b]
removetext = function(par)
{
	var strremove=par.text();
	var strexist = document.getElementById("projectIDS").value;
	strremove = strremove.replace(" X","");
	tempRemove(strexist, strremove);
	par.remove();
	var cproj;
		if(document.getElementById("countProj").value.length == 0)
			cproj=0;
		else
		 {cproj=parseInt(document.getElementById('countProj').value);
		 
		cproj=parseInt(cproj)-1;}						
		document.getElementById("countProj").value =cproj; 	 
}

function tempRemove(strexist,strremove)
{
	var b = strexist.indexOf(strremove);
	var after = strexist.indexOf(",",b);
	var newstrexist;
	var before = strexist.lastIndexOf(",",b);
	if(after!=-1)
	{newstrexist=strexist.replace(strremove+',',"");}
	else if(before!=-1)
	{newstrexist=strexist.replace(','+strremove,"");}
	else
	{newstrexist= strexist.replace(strremove,"");}

	document.getElementById("projectIDS").value=newstrexist;
}

Open in new window

0
Comment
  • 2
3 Comments
 
LVL 51

Expert Comment

by:Julian Hansen
ID: 39243782
And the issues are ?

Please give us enough info so we don't have to guess what the problem is - what are you expecting your code to do, what is it actually doing / not doing - what error messages (if any) are being displayed.

Also, if I understand you correctly, you are changing from JQuery to plain JS - why as a matter of interest?
0
 
LVL 15

Accepted Solution

by:
Gurpreet Singh Randhawa earned 0 total points
ID: 39243965
I m facing issues here

var strremove=par.text();

strremove = strremove.replace(" X","");
      tempRemove(strexist, strremove);

and function tempRemove

it breaks on the first line so probably i am guessing the bottom two that it will fail here too.
0
 
LVL 15

Author Closing Comment

by:Gurpreet Singh Randhawa
ID: 39255645
solved convert text() to innerHTML and it worked
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
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 code hide show and toggles. 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…

760 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now