Jump to content

array popping and joining


nadeemshafi9

Recommended Posts

hello hers the code

function addtoparent(id){
var relations = window.opener.document.getElementById('add_item_frm').product_relations.value;
var relArray = relations.split(",");
var action = "yes";

for(a in relArray) 
{
	if(relArray[a] == id) {
		action = "no";
		newRelArray = relArray.splice(a-1,1);
	}
}

if(action != "no") {
  		window.opener.document.getElementById('add_item_frm').product_relations.value = window.opener.document.getElementById('add_item_frm').product_relations.value + "," + id;
}
else {
	window.opener.document.getElementById('add_item_frm').product_relations.value = "," + newRelArray.join();
}
}

 

the parent window opens a child window using another function, this functiuon is used to add items to a textfeild like 324324,234324,234234 its done by checking the checkbox, but if u uncheck the checkbox it disapears of the parent windows textbox what happens is i do it on the onchange() of the check item and feed it the ID. whats happening is that i can add 3 id's 3434,32434,23432 and then when i try to remopve one they all get removed, but if i add 2 and remove 1 it works and if i add 1 and remove one it works, rember it has to remove the right id from the concatinated string in the parents textbox when i unchgeck the box it should know that the string has the id in it alrerady and force remove.

 

thanks for any sugestions at all

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.