Jump to content

cannot remove the button that I have added on page


Pawan_Agarwal

Recommended Posts

Developing CART for Online Shopping

 

I am trying to add buttons on html page and the code is working............I have some products in <SELECT> tag i.e. Product 1,Product 2,Product 3,Product 4,Product 5......... I create an array "list_array" and storing all the values in array dynamically...

 

I click on <BUTTON>ADD </BUTTON> and it reads the value from <SELECT> tag and add it into array...........To display all the products, I execute the loop and display all the items in array with a <BUTTON>REMOVE</BUTTON> in-front of every product..........

 

To delete the particular product, I can select it in <SELECT> tag and then click on delete button..........It removes the element from array .........To display the cart, I am using the loop again, and it shows all the products after clicking the <BUTTON>Display</BUTTON>

 

Now the issue that I am facing here is that I am adding <BUTTON>REMOVE</BUTTON> button when I am displaying the products that have been added in CART, the code of java_script is listed below

 

 

function display()
{
string = "";
str="";
for(j=0;j<i;j++)
{
 str = list_array[j]+"_"+j;
 string = list_array[j]+"  <button onclick='remove_me(this)' id="+str+">Remove</button><br>"+string;
}
document.getElementById('write').innerHTML = "Array:<br> " + string;
document.getElementById('i_val').innerHTML = "I: " + i;
}
 
Now, I am trying every way to make a code that will help me in removing the product by clicking on <BUTTON>REMOVE</BUTTON>, I hope I have explained everything here, so, help me to fix this issue...............
 
 
 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.