Skip to content
Advertisement

RegExp logical problem with variables in javascript

we have some checkboxes and When each of the checkes comes true, a value will be added to a single textbox.

and when each of the checkes comes false, their own value will be deleted.

I hope I explained well.

any way… here is my code:

JavaScript

I do know that it is not a clean code:)

btw ab is my textbox. and c is my value.

but problem is : reg= new RegExp(c, 'g'); part doesn’t accept c as value.

it works when I do this:reg= new RegExp('word', 'g');

but it doesn’t accept any variable.

pls help.

Advertisement

Answer

Try :

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement