Jump to content
Sign in to follow this  
gunaweb

Replace javascript when checkbox state changes

Recommended Posts

Hi All,

 

How can I replace the "Non-recurring default script" with "Recurring script" buttons when the checkbox is checked?

 

I can only go this far: http://jsfiddle.net/k53nv/

 

Buttons sample:

 

Non-recurring script (default):

<script type="text/javascript" src="https://03a4d20.netsolstores.com/add-a-store.aspx?pid=4&lid=8"></script>Recurring script:

<script type="text/javascript" src="https://03a4d20.netsolstores.com/add-a-store.aspx?pid=1&lid=8"></script>

 

I need to drop the full HTML code/script to my WordPress website.

 

Thank you in advance.

Edited by gunaweb

Share this post


Link to post
Share on other sites

I would suggest including both scripts in the one function/script, set a variable based on the checkbox setting and use an if statement to execute the appropriate code.

Share this post


Link to post
Share on other sites

Hi jonhcc, thank you for your suggestion but that's where I am stuck now. I am a web designer who forced myself to do more programming :sorry:...and can't go beyond that. Do you think you can give me an example with the actual codes? Cheers!

Share this post


Link to post
Share on other sites

Not exactly clear about what you want to achieve, but in your check function instead of setting 'result', can't you just insert the recurring or non-recurring code (or a call to it) as appropriate.

 

Edit: It occurred to me after answering with the sentence above that you may want another button, the action of which is altered depending on the setting of the checkbox. Is that correct?

Edited by johncc

Share this post


Link to post
Share on other sites

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.   Paste as plain text instead

  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.

Loading...
Sign in to follow this  

×
×
  • Create New...