Title: Reading parameter with javascript
Last modified: April 25, 2022

---

# Reading parameter with javascript

 *  Resolved [Juha Metsäkallas](https://wordpress.org/support/users/juhametsakallas/)
 * (@juhametsakallas)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/reading-parameter-with-javascript/)
 * This might be a FAQ, but can you read parameter value with javascript?
 * Say, you call a shortcode `[sc name="mySC" name="Joe"]` which contains javascript
   like this
 *     ```
       <script>
       if(name == "Joe")
       {
         …
       }
       </script>
       ```
   

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Author [vaakash](https://wordpress.org/support/users/vaakash/)
 * (@vaakash)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/reading-parameter-with-javascript/#post-15593756)
 * Hi [@juhametsakallas](https://wordpress.org/support/users/juhametsakallas/),
 * Shortcoder is unaware of the code or what it does.
 * But using “[custom parameters](https://www.aakashweb.com/docs/shortcoder/custom-parameters/)”
   you can replace content dynamically.
 * (make sure you don’t use the “name” as the parameter since it is used to identify
   the shortcode itself)
 *     ```
       <script>
       if(name == "%%username%%")
       {
         …
       }
       </script>
       ```
   
 * Now you can insert the shortcode like `[sc name="myshortcode" username="Joe"]`
 * This will insert the code with `%%username%%` replaced with `Joe`
 * Thanks,
    Aakash
 *  Thread Starter [Juha Metsäkallas](https://wordpress.org/support/users/juhametsakallas/)
 * (@juhametsakallas)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/reading-parameter-with-javascript/#post-15594049)
 * My use case was a little more complex and I tried to simply it, but it seems 
   I simplified it too much. And of course, after an hour from my posting I came
   up with a solution, which while not perhaps the prettiest one, works and is reasonably
   easy to maintain.
 * A website has a WPForms form for subscribing a newsletter. Actually there need
   to be six forms for the same thing. The site has subsections in three languages
   and it seems that there must be two variants of the form for each language depending
   on where the form should be displayed on a page, whether at the bottom or at 
   a sidebar (do not ask why, I did not create the site).
 * What I ended up doing was six forms (three languages by two CSS settings), but
   only three shortcodes (for three languages) to output the form title and description
   and the shortcodes have a custom parameter for picking up the right variant of
   the form.
 * Anyway, thank you!
 * PS. This is an awesome plugin.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Reading parameter with javascript’ is closed to new replies.

 * ![](https://ps.w.org/shortcoder/assets/icon.svg?rev=2222236)
 * [Shortcoder — Create Shortcodes for Anything](https://wordpress.org/plugins/shortcoder/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/shortcoder/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/shortcoder/)
 * [Active Topics](https://wordpress.org/support/plugin/shortcoder/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/shortcoder/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/shortcoder/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [Juha Metsäkallas](https://wordpress.org/support/users/juhametsakallas/)
 * Last activity: [3 years, 11 months ago](https://wordpress.org/support/topic/reading-parameter-with-javascript/#post-15594049)
 * Status: resolved