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 8702971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:46:45+00:00 2026-06-13T02:46:45+00:00

Usually I put JavaScript like this : <head> <title>Title goes here</title> <script> some JavaScript

  • 0

Usually I put JavaScript like this :

<head>
<title>Title goes here</title>
<script>
some JavaScript here
</script>
</head>

<body>
some codes here
</body>

but now I have a case that JavaScript code must be generated and equal with number of LI tags on HTML file:

$('#manage-1').click(function(e) { 
    $(this).next(".manage-content-wrap").find(".manage-content").load("test-manage-1.php");
    e.preventDefault();
});
$('#manage-2').click(function(e) { 
    $(this).next(".manage-content-wrap").find(".manage-content").load("test-manage-2.php");
    e.preventDefault();
});

I have an idea to create that JavaScript from PHP by modifying #manage-1 with variable like this : #manage-$i and any other dynamic parts.

but, is it possible to put tag inside like this :

<head>
<title>Title goes here</title>
<script>
some JavaScript here

<?php
PHP code inside script tags
?>

</script>
</head>
  • 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-13T02:46:46+00:00Added an answer on June 13, 2026 at 2:46 am

    Ok, I think we can fix this with just a little refinement of your technique.

    You really don’t need multiple .click handlers, you need to have a better selector strategy.

    Let’s say you surround your LI’s with this:

    <ul class="managers">
        <li><a href="" id="manage-1">Link Text 1</a></li>
        <li><a href="" id="manage-2">Link Text 2</a></li>
        <li><a href="" id="manage-3">Link Text 3</a></li>
        <li><a href="" id="manage-4">Link Text 4</a></li>
    </ul>
    

    Now, you really only need one .click handler:

    $(".managers li a").click(function(evt) {
        evt.preventDefault();
        var mID = $(this).attr("id");
        $(this).next(".manage-content-wrap").find(".manage-content").load("test-" + mID + ".php");
    });
    

    Mind you, you might have to modify how you find your proper .manage-content element, in this fashion, but you should get the idea.

    In this way, also, you’re not tying your interaction on the presentation side with your data inextricably, and you DRY up your code a bit. Almost any time you see yourself needing to spit out auto-generated code that is exactly the same except for a couple details, there is an opportunity to simplify the approach.

    Hope this helps!

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

Sidebar

Related Questions

Can some body tell me the reason why we usually put const and &
I usually put my mod_rewrite conditions in an .htaccess file, but this is a
I usually put my connection string to a separate file, adding something like this
When I first started with Javascript, I usually just put whatever I needed into
I'm working through some tutorials and examples of java.util.concurrent package. Usually example authors put
While doing performance testing on windows, i usually use perfmon. But when i put
I'm trying to put some simple jQuery code into the Wordpress header (usually just
I have been searching for an answer to this question for some time now,
When I want to use a branch in CC, I usually put something like
I'm learning some C# and in the tutorials, they usually put most of the

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.