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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:19:17+00:00 2026-06-09T21:19:17+00:00

I am new to JavaScript/jQuery. I have the following HTML code that’s automatically generated

  • 0

I am new to JavaScript/jQuery. I have the following HTML code that’s automatically generated by framework.

<tr class="alternate-row">
    <td>17 July, 2012</td>
    <td>AM Shipment</td>
    <td>Generated</td>
    <td>
        <form method="post" action="" id="ListTruckSheets_o_7" class="basic-form" onsubmit="javascript:submitFormDisableSubmits(this)" name="ListTruckSheets_o_7">//I have the name of this form.
            <input type="hidden" name="shipmentId"  value="10310" id="ListTruckSheets_shipmentId_o_7">
            <input type="hidden" name="Report" id="truckSheet_o_7" onclick="javascript:setSelectedRoute(this, 10310);">
            <input type="hidden" name="abstractReport" id="routeAbstract_o_7" onclick="javascript:setSelectedRoute(this, 10310);">
            <input type="hidden" name="milkDeliverySchedule" id="deliverySchedule_o_7"  onclick="javascript:setSelectedRoute(this, 10310);">
            <input type="hidden" name="cancelShipment" id="ListTruckSheets_cancelShipment_o_7">
        </form>
        <td>
            <a class="buttontext" href="/myportal/control/KVGenerateTruckSheet.txt?shipmentId=10310&amp;reportTypeFlag=trucksheet"  target="_blank" onclick="javascript:setSelectedRoute(this, 10310);" title="Report">Truck Sheet Report</a>
        </td>
        <td>
            <a class="buttontext" href="/myportal/control/KVGenerateTruckSheet.txt?shipmentId=10310&amp;reportTypeFlag=abstract" target="_blank" onclick="javascript:setSelectedRoute(this, 10310);" title="Abstract Report">Route Abstract Report</a>
        </td>
        <td>
            <a class="buttontext" href="/myportal/control/MilkDeliveryScheduleReport.txt?hipmentId=10310&amp;reportTypeFlag=milkDeliverySchedule" target="_blank" onclick="javascript:setSelectedRoute(this, 10310);" title="Milk Delivery Schedule">Delivery Schedule</a>
        </td>
        <td>
            <form method="post" action="/myportal/control/cancelLMSShipment" target="_blank"    onsubmit="javascript:submitFormDisableSubmits(this)" name="ListTruckSheets_o_7_0_o_cancelShipment">
                <input name="shipmentId" value="10310" type="hidden">
            </form>
            <a class="buttontext" href="javascript:document.ListTruckSheets_o_7_0_o_cancelShipment.submit()">Cancel</a>
        </td>
</tr>

Using onclick I have called a JavaScript function which gets the url and add a parameter to it. I have the name or Id of the form(‘ListTruckSheets_o_7’). Using form name or Id I need to find the parent tr and identify the right td I want and set parameter to its url. This is the code I am currently messing with.

function setSelectedRoute(existingUrl, shipmentId) {
     var form = $("input[value=" + shipmentId + "]").parent(); //formName: ListTruckSheets_o_7
     var routeId = form.find("option:selected").text();
     var resultUrl = existingUrl + "&facilityId=" + routeId;
     $('.buttontext').attr('href', resultUrl); // this is setting resultUrl to all the .buttontext class elements but I need to set resultUrl to only specific selected td.
}

So, may be, I need to find the parent tr and get back to the specific td and set resultUrl to it. I have no idea how to do it. I hope I am clear with my question.

  • 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-09T21:19:19+00:00Added an answer on June 9, 2026 at 9:19 pm

    You can test this:

    form
      .closest('tr')   // go parent tr of form
      .find('.specific_selected_td') // find td, here specific_selected_td is 
                                     // assumed class to selected td
                                     // you may have something different 
      .find('a')  // find anchor tag within that specific td
      .attr('href', resultUrl); // set href
    

    After edit

    Change

    $('.buttontext').attr('href', resultUrl); 
    

    to

    $(existingUrl).attr('href', resultUrl);
    

    Here, existingUrl refers to the clicked a.

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

Sidebar

Related Questions

I have the following Javascript and Html code that works fine in an MVC4
I have the following code..... <head> <script src=Scripts/jquery-1.7.2.min.js type=text/javascript></script> <script src=Scripts/hidepanel.js type=text/javascript></script> </head> <body>
I have the following jquery code in my view <script type=text/javascript> $(document).ready(function () {
I'm really new to JavaScript and jQuery. My question is this. I have two
I have just started learning Jquery and am new to writing javascript (I am
I'm new to JQuery/Javascript etc... based on the following article: How to make an
im new to jquery and javascript.. Here is the code, this is a sample,
I have the following JQuery code which does similar functionality like Stackoverflow where the
I have the following code in my models: Class Farm < ActiveRecord::Base has_many :farm_products,
I have the following code that populates a Drop Down List and auto submits

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.