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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:19:03+00:00 2026-05-23T00:19:03+00:00

I have two javascript functions, the first one is working, teh second is working

  • 0

I have two javascript functions, the first one is working, teh second is working but not echoing the correct value in the hidden inputs.

Ive manage to get the last hidden input value correct but I’m not sure how

var customTicketsArr = Array();

function EditEventAddTicket(){
    alertWrongTime = false;
    var TicketName = jQuery("#ticketname").val();
    var TicketPrice = jQuery("#ticketprice").val();
    var ticketquantity = jQuery("#ticketquantity").val();

    var storeString = "TicketName" + TicketName + "TicketPrice" + TicketPrice + "Quantity" + ticketquantity + '';
    customTicketsArr.push(storeString);
    EditEventUpdateTickets(true);
}


function EditEventUpdateTickets(fade){
   jQuery("#custom_tickets_string").val(customTicketsArr);
   var output = "";
   var style = "";
   for (i = customTicketsArr.length-1; i >= 0; i--){
       ticketname = customTicketsArr[i].split("TicketName");

           ticketprice = customTicketsArr[i].split("TicketPrice");

           ticketquantity = customTicketsArr[i].split("Quantity");
       if(fade){
           if (customTicketsArr.length - 1 == i){
               style = "display: none; ";
               var fadeInDiv = i;
           } else {
               style = "";
           }
       }
       if (i % 2 == 1) { style += "background-color: #660000; "}
       html = "<div id='customticket" + i + "' class='customeventbase' style='" + style + "'>";
       html += '<input type="hidden" name="customTicketid[' + i + '][Name]" id="customticketName' + i + '" value="'+ ticketname  + '" />';
           html += '<input type="hidden" name="customTicketid[' + i + '][Price]" id="customticketPrice' + i + '" value="' +ticketprice[1]  +'" />';
           html += '<input type="hidden" name="customTicketid[' + i + '][Quantity]" id="customticketQuantity' + i + '" value="'+ ticketquantity[1]  +'" />';

       html += '<button class="customeventdel" type="button"  onClick="EditEventRemoveDate(' + i + ')"></button>';
       html += '<div class="clear"></div>';
       html += '</div>\n';

       output += html;
   }
   output += "<input type='hidden' id='custom_ticket_info' name='custom_ticket_info' value='" + customTicketsArr + "' />";
   jQuery("#custom_ticket_container").html(output);
   if(fade){
      setTimeout("EditEventfadeInDiv(" + fadeInDiv +")", 10);
   }

}

this outputs:

    <div style="background-color: #660000; " class="customeventbase" id="customticket1">
<input type="hidden" value=",testTicketPrice50Quantity44" id="customticketName1" name="customTicketid[1][Name]">
<input type="hidden" value="undefined" id="customticketPrice1" name="customTicketid[1][Price]">
<input type="hidden" value="44" id="customticketQuantity1" name="customTicketid[1][Quantity]">
<button onclick="EditEventRemoveDate(1)" type="button" class="customeventdel"></button>
<div class="clear"></div></div>

the values for the first two hidden fields are incorrect

  • 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-23T00:19:04+00:00Added an answer on May 23, 2026 at 12:19 am

    why do you save it as a string? I would recommend storing it in an object:

    function EditEventAddTicket(){
        alertWrongTime = false;
        var TicketName = jQuery("#ticketname").val();
        var TicketPrice = jQuery("#ticketprice").val();
        var ticketquantity = jQuery("#ticketquantity").val();
    
        var ticket = {"TicketName": TicketName, "TicketPrice": TicketPrice, "Quantity": ticketquantity};
        customTicketsArr.push(ticket);
        EditEventUpdateTickets(true);
    }
    

    and then you can simply load the data:

    for (i = customTicketsArr.length-1; i >= 0; i--){
           ticketname = customTicketsArr[i].TicketName;
           ticketprice = customTicketsArr[i].TicketPrice;
           ticketquantity = customTicketsArr[i].Quantity;
    
           // ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two ajax functions and use the first one to pass some data
Hello I have two dependants select box, the second one is popularited after onchange
I'm working on key handling in Javascript. I have done some research and I'd
I have a Javascript function in my website. I don't know Javascript very well
This is my first time using JQuery in any of my projects. I have
Im perplexed by this one. jQuery.height() is coming back with different values in Firefox
In have a controller class that handle a Contact object. In this controller I
We have a web application (it is a game) with lots of various forms
A requirement for a current project of mine involves highlighting an HTML element in
I'm converting procedural JS to OO and would appreciate any help. In a nutshell,

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.