Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8473365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T17:19:54+00:00 2026-06-10T17:19:54+00:00

I have a pre-written code in Php where JavaScript function is called echo <a

  • 0

I have a pre-written code in Php where JavaScript function is called

echo "<a href='javascript:submittemplate(".$temprow['templateid'].");'>".$temprow["templatename"]."</a></td>";

and the script is :

  <script>
        function submittemplate(templateid)
        {

            window.document.location.href = 'index.php?module=Users&action=UsersAjax&file=TemplateMerge&templateid='+templateid;

        }
 </script>

Now I wanted to pass one more argument In this function.

What I did was this :

echo "<a href='javascript:submittemplate(".$temprow['templateid'].",".$mode.");'>".$temprow["templatename"]."</a></td>";

<script>
function submittemplate(templateid,mode)
{
alert("anything");
    window.document.location.href = 'index.php?module=Users&action=UsersAjax&file=TemplateMerge&templateid='+templateid;

}
</script>

The Later code does not work.
What am I doing wrong ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T17:19:56+00:00Added an answer on June 10, 2026 at 5:19 pm

    if the mode variable is a string this will raise an error.

    e.g. alert(myString Is Here) // throw error

    it should be alert("myString Is Here");

    so you must add quotation to be like this :

    echo "<a href='javascript:submittemplate(".$temprow['templateid'].",\"".$mode."\");'>"
    

    note the \"

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using some pre-written JavaScript from polldaddy. They have a JavaScript option which,
I have a web application written in pure JavaScript (no pre-generated HTML except for
I have the following code written, <?php require_once products.php; $test = new Products; $array
I have written some JavaScript code that will read from the Google Maps API
I have a pre-written code which is used to cipher the given plain text
I have written/found a php script and I don't understand why it's working one
I have written a script in haskell named testscript with the following code: #!/usr/bin/env
I have the following code, which is written for the Titanium framework for mobile
I have an unmanaged DLL that gets called from .NET with pre-allocated buffers to
Is there a library in Java, that allows adding pre-written VBA code into a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.