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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T13:56:03+00:00 2026-05-13T13:56:03+00:00

I have a table where I display some information for a user to approve

  • 0

I have a table where I display some information for a user to “approve” or “deny” certain projects. I created two images: a cross sign for denials, and a check sign for approvals. On each click, I am adding the unique id to its respective hidden form field (rejectedProjs and approvedProjs). In addition, if a user clicked on “deny” then I am displaying a text box so that they can enter a reason. This is what I have so far:

 $("a[name^=reject-]").each(function() {

     var name = $(this).attr('name');    
     var p_project_number = name.split('-')[1]; 
   $("a[name=reject-"+p_project_number+"]").tipbox("Reject pricing for "+p_project_number, 0, "reject-"+p_project_number);
     $(this).click(function() { 
$("textarea[name=rejReason-"+p_project_number+"]").show();   
rP = $("#rejectedProjs").val();
$("#rejectedProjs").val(rP+','+p_project_number);
alert('rejects: '+$("#rejectedProjs").val());
     });   
 });

There are two problems. First, if I click on the deny button twice for the same project, the alert box will display the project number twice. How can I check the $(“#rejectedProjs”).val() to see if that project number is already there? Second, if say I deny first and then approve, I need to remove that project from $(“#rejectedProjs”).val(). Not sure how to do this. thanks in advance.

  • 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-13T13:56:03+00:00Added an answer on May 13, 2026 at 1:56 pm

    I’d use an array instead of a hidden input. This way you can easily search through the array for already existing values, add new values, and remove values. Then, after the manipulation is complete set the value of a hidden input to the array using array.join()

    A very simple example will look something like this:

    var accepted = new Array();
    var rejected = new  Array();
    
    function process(action, id) {
        if(action == "accept") {
            // look for item in accepted array, add if doesnt exist
            if(findInArray(accepted, id) == -1) {
                accepted.push(id);
            }
    
            // look for item in rejected array, remove if exists
    
            var rejectedIdx = findInArray(rejected, id);
            if(rejectedIdx == -1) {
                accepted.splice(rejectedIdx, 1);
            }
        } else {
            // The same, but for rejected ids. Not included for brevity...
        }
    
        // update hidden inputs
        $("hiddenAccepted").val(accepted.join(","));
        $("hiddenRejected").val(rejectedaccepted.join(","));
    }
    
    function findInArray(array, value) {
        for(var i = 0; i < array.length; ++i) {
            if(array[i] == value] return i;
        }
        return -1;
    }
    

    and dont forget to actually include the hidden inputs in your page:

    <input type="hidden" name="hiddenAccepted" />
    <input type="hidden" name="hiddenRejected" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Database table that I want to display in a DataGridView. However,
Many applications have grids that display data from a database table one page at
i have ajax script for select some infomrations. If the user selects a choice,
I have a script that appends some rows to a table. One of the
I have a JIRA environment which already has some information and i'm trying to
I have a custom UITableViewCell with two labels ( UILabel ). The table cells
I have 13 columns in a table. When I display it in a <h:dataTable>
I have a GWT CellTable<MyType> . This table have rows which should display a
I created an asp.net application that fills a table with information from a database,
I have a webpage on my site that displays a table, reloads the XML

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.