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

  • Home
  • SEARCH
  • 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 6223943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:34:45+00:00 2026-05-24T08:34:45+00:00

I have this page <script type=text/javascript> $(document).ready(function () { $(#delete).click(function () { if (confirm)

  • 0

I have this page

<script type="text/javascript">
$(document).ready(function () {
    $("#delete").click(function () {
        if (confirm) {
            $("#divSchedules").load('@Url.Content("~/Export/ScheduleDelete/")');
        }
        else {
            return false;
        }
    });
}); 
</script>
<table>
<tr>
    <td>Description</td>
    <td>Schedule</td>
    <td>&nbsp;</td>
</tr>
@foreach (var item in Model)
{
    <tr>
        <td>@item.Description</td>
        <td>@item.Schedule</td>
        <td><a href="@Url.Action("ScheduleEdit", new { @id = item.Id })" class="popLink"><img alt="" src="@Url.Content("~/Content/images/icons/edit.gif")" style="border:none;" /></a>
            <img alt="" src="@Url.Content("~/Content/images/icons/delete.gif")" style="border:none;" id="delete" /></td>
    </tr>
}
</table>

The Jquery function there is being triggered by elements with id=”delete”, for instance, a img tag.

Can someone help me please, I need to have this Jquery function to have a parameter passed using onclick like for example

$(document).ready(function () {
    $("#delete").click(function (id) {
        if (confirm) {
            $("#divSchedules").load('@Url.Content("~/Export/ScheduleDelete/" + id)');
        }
        else {
            return false;
        }
    });
}); 

<img alt="" src="@Url.Content("~/Content/images/icons/delete.gif")" style="border:none;" onclick="delete(@item.Id)" />

I have added id on jquery as parameter. I tried that but always having compile error “id not in context” thing.

Could someone please help? Thank you very much.

  • 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-05-24T08:34:47+00:00Added an answer on May 24, 2026 at 8:34 am

    I think you need to change this:

    $("#divSchedules").load('@Url.Content("~/Export/ScheduleDelete/" + id)');
    

    to this:

    $("#divSchedules").load('@Url.Content("~/Export/ScheduleDelete/")' + id);
    

    And you can’t have multiple elements with id="delete". You should use a className instead to “group” elements together. The IDs should be the unique identifiers from your server. So my thinking is to give all your delete button the ‘delete’ class, and attach a click handler to all elements of that class. The ID of the clicked element can be easily extracted using DOM object property access.

    In code:

    <img alt="" src="@Url.Content("~/Content/images/icons/delete.gif")" style="border:none;" class="delete" id="@item.Id" />
    
    $(document).ready(function () {
        $(".delete").click(function() {
    
            // get ID of clicked image
            var id = this.id
            if (confirm) {
    
                // concatenate ID to URL
                $("#divSchedules").load('@Url.Content("~/Export/ScheduleDelete/")' + id);
            }
            else {
                return false;
            }
        });
    }); 
    

    Keep in mind, that IDs should not start with a number so you may or may not need to use a prefix (I don’t know what you’re IDs look like).

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

Sidebar

Related Questions

I have this jQuery code: <script type=text/javascript> $(document).ready(function() { $('.vote_up').click(function() { alert ( test:
I have a page as below: <head> <script type="text/javascript" src="jquery-1.6.1.js"></script> <script type="text/javascript"> $(document).ready( function()
I have the following and in this order: <script type=text/javascript> $(document).ready(function(){ var overwrite =
Okay, I have this code: <script language=javascript type=text/javascript> <!-- function requestPage(page) { var request
I have this script loaded on a page: (function() { window.alert('bookmarklet started'); function AjaxSuccess(data,
I have this script on my html page: <script language='javascript'>parent.resizeTo(550,510);</script> I'd like to add
i have script like this.... <head> <meta http-equiv=content-type content=text/html; charset=iso-8859-1 /> <meta name=author content=bbbbb
i have this script $content = string if(!isset($_GET['page'])){ $page = 1; } else{ $page
I have this html page which is very simple, it contains a text box
I'm attempting to select all <script type=text/html> tags in a page. I use <script>

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.