Peruttu

Complete a JavaScript statement to remove an array value on click

This is the existing statement:

<script>

var subs_array = [];

$('.sub').one('click', function(e){

[login to view URL]();

[login to view URL]( $(this).data('user-subscription') );

$('#sub').val(subs_array);

});

</script>

<!-- the html -->

<a href='#' class="sub" data-user-subscription='Magazine #1'>Subscribe to #1</a>

<a href='#' class="sub" data-user-subscription='Magazine #2'>Subscribe to #2</a>

<a href='#' class="sub" data-user-subscription='Magazine #3'>Subscribe to #3</a>

<input type="text" class="form-control" id="sub" size="50" value="" placeholder="Magazine #1, Magazine #2, Magazine #3">

The problem:

When you click on the link, it adds the value into the array and it is added into the input field but if you click again, it does not remove the value.

Modify the above statement so when you click on a link the first time, it adds the value into the array but if you click again, it removes the value.

Taidot: Javascript, jQuery / Prototype

Näytä lisää: remove javascript ctrl click, read array xml javascript, javascript tabs complete, javascript remove javascript code, remove javascript tags java, asp remove javascript, asp remove javascript code, remove javascript codes, remove javascript tags, java remove javascript tags, remove click activate remove control, remove javascript website, javascript calculator complete code, remove javascript, click drop menu javascript

Tietoa työnantajasta:
( 5 arvostelua ) Gold Coast, Australia

Projektin tunnus: #14795540

46 freelanceria on tarjonnut keskimäärin %project_bid_stats_avg_sub_26% %project_currencyDetails_sign_sub_27% tähän työhön

superwanchiu

hello nice to meet you. i am very interested in your project i have rich experience for javascript . your project is very easy for me. i can complete your project in a short time. please send your message so that Lisää

$15 AUD 1 päivässä
(24 arvostelua)
0.0
krunalk529

I have 2.8 years of professional experience in both front-end and back-end technologies Front end: Angularjs, jquery, javascript, html, css, bootstrap Back end : java, spring , hibernate Database: mssql, mysql, mongodb

$16 AUD 1 päivässä
(0 arvostelua)
0.0
lucks15022

I got the solution for this and I have the code ready with me. I will provide it to you the code in PM Could not provide here since this allows only 200 chars Relevant Skills and Experience I have lot of experience in Lisää

$17 AUD 1 päivässä
(0 arvostelua)
0.0
MisterWatson

edit: I now have a working solution. hit me up when you're ready to test it. theres actually a typo with the click event handler and your code does not have a function call to actually remove an existing value. I w Lisää

$20 AUD 0 päivässä
(9 arvostelua)
0.0
sibinx7

Sir, Please check this code ... remove one and use .on('click', function(){}) or simple .click(function(){}) // subs_array = $.grep(subs_array, function(item){ return item !== selectedValue ; });// Relevant Skills and Lisää

$10 AUD 1 päivässä
(6 arvostelua)
0.0
RaviVadaliya

Hello Sir, I have 5 year professional experience in IT industries. Below are my technical specialities. Asp.Net, jQuery, C#, Microsoft SQL Server, Web Service, WCF I will fixed your issue asap. Relevant Skills and Exp Lisää

$15 AUD 1 päivässä
(0 arvostelua)
0.0
diegofpr

A proposal has not yet been provided

$15 AUD 0 päivässä
(8 arvostelua)
0.0
mmpatel009

Hello, Hope you are doing well, JSfiddler like is generated for you, please initiate message board so I can provide you Relevant Skills and Experience I have already corrected your script in local and availab Lisää

$10 AUD 1 päivässä
(26 arvostelua)
0.0
tlchung

I am a skilled js developer, I can make the js script remove the value when you click again. let discuss more via private message, thanks. Relevant Skills and Experience I am a skilled js developer, I can make the js Lisää

$20 AUD 1 päivässä
(113 arvostelua)
0.0
jimsproject102

hi sir this my demo, [login to view URL] Relevant Skills and Experience javascript,jquery,html Proposed Milestones $15 AUD - deliver script

$15 AUD 1 päivässä
(0 arvostelua)
0.0
Weborchid

We are the team that visualize, pens down ideas, adds in the essential ingredient of creativity and imagination and cooks up that perfect dish called brand. Lets discuss in details.

$55 AUD 1 päivässä
(6 arvostelua)
0.0
sachinraghav

I can do this project. I can start it right now. Message me for more details. Relevant Skills and Experience JavaScript, Jquery, html Proposed Milestones $10 AUD - Final Project

$10 AUD 1 päivässä
(2 arvostelua)
0.0
alokrajiv

It is easy and, this being my first project on freelancer I have put a minimum bid. Why me? : Bronze Javascript Star holder on JS: [login to view URL] Relevant Skills and Experience Doing Ja Lisää

$10 AUD 1 päivässä
(0 arvostelua)
0.0
florinbacu

A proposal has not yet been provided

$15 AUD 1 päivässä
(30 arvostelua)
0.0
celalaybar

Hello. I can help you. Relevant Skills and Experience I am good at JavaScript, HTML and CSS. Proposed Milestones $10 AUD - Done

$10 AUD 0 päivässä
(48 arvostelua)
0.0
$20 AUD 1 päivässä
(0 arvostelua)
0.0
navjot12

Hi , I have completed this project at my end.I am new at freelancing,dont know how exactaly write [login to view URL] my first bid. I have studied your requirement ,its very simple for me ,has been done. Thanks

$17 AUD 1 päivässä
(0 arvostelua)
0.0
kofzx123

I am referring to the price of other freelancer, set an average price Relevant Skills and Experience Used to javascript, the operation of the array related knowledge Proposed Milestones $17 AUD - The first part Lisää

$14 AUD 1 päivässä
(0 arvostelua)
0.0
$17 AUD 1 päivässä
(0 arvostelua)
0.0
BaNgan

Hi, We can check existence of the value and remove it in second click Relevant Skills and Experience Feel free to contact me via Skype: bangank36, my timezone is GMT+7. My resume website: [login to view URL] Regar Lisää

$17 AUD 1 päivässä
(220 arvostelua)
0.0