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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T09:52:31+00:00 2026-05-19T09:52:31+00:00

I have one last thing left on a project and its a doozy. Not

  • 0

I have one last thing left on a project and its a doozy. Not only is this my first web application, but its the first app i used Jquery, CSS and MVC. I have no idea on how to proceed with this.

What i am trying to do is:

In my controller, a waste item is validated, and based on the results one of these things can happen. The validation is completed, nothing bad happens, which sets ViewData[“FailedWasteId”] to -9999. Its a new waste item and the validation did not pass, which sets ViewData[“FailedWasteId”] to 0. Its an existing waste item and the validation did not pass, which sets ViewData[“FailedWasteId”] to the id of the waste item.

This ViewData[“FailedWasteId”] is set on page load using

    <%=Html.Hidden("wFailId", int.Parse(ViewData["WasteFailID"].ToString()))%>

When the validations do not pass, then the page zooms (by window.location) to an invisible div, opens the invisible div etc. Hopefully my intentions are clear with this poor attempt at jquery.

The new waste div is and the existing item divs are dynamically generated (this i know works) “>

So my question here is… Help? I cant even get the data to parse correctly, nor can i even get the conditionals to work. And since this happens after post, i cant get firebug to help my step through the debugger, as the script isnt loaded yet.

        $(document).ready(function () {
            var wasteId = parseInt($('#wFailId').text());

            if (wasteId == -9999) {
                //No Issue
            }
            else if (wasteId < 0) {
                //Waste not saved to database
            }
            else if (wasteId == 0) {
                //New Waste
                window.location = '#0';
                $('.editPanel').hide();
                $('#GeneratedWasteGrid:first').before(newRow);
                $('.editPanel').appendTo('#edit-panel-row').slideDown('slow');
            }
            else if (wasteId > 0) {
                //Waste saved to database
            }
        });
  • 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-19T09:52:32+00:00Added an answer on May 19, 2026 at 9:52 am
    var wasteId = parseInt($('#wFailId').text());
    

    This line is wrong. It attempts to get the text contents inside the hidden input element, which is the empty string because no contents exist (e.g. “Hello” in <span id="foo">Hello</span>). This causes parseInt() to return the value NaN (Not a Number), causing every one of your conditions to fail but not causing any JavaScript exception to be thrown.

    The value you are looking for instead exists as the attribute value of the element, retrievable using .val():

    var wasteId = parseInt($('#wFailId').val(), 10); // or use:
    var wasteId = +$('#wFailId').val();
    

    (JavaScript’s unary plus operator is what I would use to cast to a number if necessary. Note that in any case, it is bad practice to use parseInt() without specifying the base/radix 10, because otherwise 010 is interpreted as an octal number: 8 in decimal.)

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

Sidebar

Related Questions

I'm nearly done with a trackback system for my website, but have one last
We are currently evaluating upgrading from XP to Windows 7, but have one last
I have first names stored in one table and last names stored in another.
I have been busy integrating Wordpress to one of a CakePHP application.Last Monday I
.NET 1.1 lacks ParameterizedThreadStart (I have to use 1.1 because it's the last one
This is my first time using stackoverflow for a question, I have read a
I may seem ignorant but I have not found much information about how to
I have newly discovered Perl forking and I am quite in love. But one
Okay, I've almost got this thing finished! Many thanks to all who have helped
I finally have finished a Web Application and now I have to make it

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.