5 Replies - 265 Views - Last Post: 09 April 2019 - 09:03 AM Rate Topic: -----

#1 DarenR   User is offline

  • D.I.C Lover

Reputation: 624
  • View blog
  • Posts: 4,165
  • Joined: 12-January 10

why isnt my hidden field setting?

Posted 09 April 2019 - 05:35 AM

i have a hidden field i need to set so i can grab the info from the back end

for some reason no matter what i do it doesnt set

here is the code:

 <asp:TemplateField headertext="Remaining Balance"  ItemStyle-CssClass="DataGridTextNumeric" HeaderStyle-CssClass="DataGridColumnHeader">
                                            <ItemTemplate>
                                                <asp:TextBox ID="txtWIPBLK_RemainingOnHand" name="txtBLK_RemainingOnHand" runat="server" Text='<%# Bind("WIPBLK_RemainingOnHand")%>' CssClass="DataGridTextNumeric"  ></asp:TextBox>
                                             <asp:HiddenField runat="server" id="hdnVal" value="" />
                                               
                                            </ItemTemplate> 
                                        </asp:TemplateField>




javascript:
function fnWIPBLKInputCheck(txtControl, inControl) {
    if ((isNaN(txtControl.value)) || (txtControl.value == '') || (txtControl.value < 0)) {
        txtControl.focus();
        if (inControl == 'TAWIPBLK') {
            alert('Please enter valid grade on hand');
            return false;
        }

        if (inControl == 'CSWIPBLK') {
            alert('Please enter valid production tons');
            return false;
        }
    }

    var gRow = txtControl.parentNode.parentNode;

    var TABLK = parseFloat(gRow.cells[3].getElementsByTagName("input")[0].value.replace(',', ''));
    var CSBLK = parseFloat(gRow.cells[4].getElementsByTagName("input")[0].value.replace(',', ''));
    //var rmBLK = gRow.cells[5];
    var rmBLK = gRow.cells[5].getElementsByTagName("input")[0];
    //var test = document.getElementsByName('txtWIPBLK_RemainingOnHand')[0].value
    var remainingBLK = (TABLK - CSBLK);
    if (isNaN(remainingBLK) && isNaN(TABLK)) {
        remainingBLK = 0;
    }
    else if (isNaN(remainingBLK) && !isNaN(TABLK)) {
        remainingBLK = TABLK;

    }
   // rmBLK.innerHTML = remainingBLK.toFixed(2);
   
   

    rmBLK.value = remainingBLK.toFixed(2); 
    alert("here");<<----- works all the way to here
    var myHidden = document.getElementById("<%= hdnVal.ClientID %>");  <<--- doesnt work here where i am looking for the field
    myHidden.value = remainingBLK.toFixed(2);
   // document.getElementById('<%=hdnVal.ClientID%>').value = remainingBLK.toFixed(2);
    alert(myHidden.value);
   // hidden.value = remainingBLK.toFixed(2);
    alert("there");
    
    return true;
}



you can see from the java script that i have tried several ways to set the value and not one works


thoughts?

Is This A Good Question/Topic? 0
  • +

Replies To: why isnt my hidden field setting?

#2 DarenR   User is offline

  • D.I.C Lover

Reputation: 624
  • View blog
  • Posts: 4,165
  • Joined: 12-January 10

Re: why isnt my hidden field setting?

Posted 09 April 2019 - 07:35 AM

i just decided to do math on the backside since the hiddenfield didnt want to work
Was This Post Helpful? 0
  • +
  • -

#3 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15160
  • View blog
  • Posts: 60,694
  • Joined: 12-June 08

Re: why isnt my hidden field setting?

Posted 09 April 2019 - 07:38 AM

You can't use jquery, right?

$("#blahblah").val("some vale");


Also keep in mind some fields aren't quite named what you expect at run time. So it's always a good idea to f12 and check what the hidden field is actually named.
Was This Post Helpful? 0
  • +
  • -

#4 DarenR   User is offline

  • D.I.C Lover

Reputation: 624
  • View blog
  • Posts: 4,165
  • Joined: 12-January 10

Re: why isnt my hidden field setting?

Posted 09 April 2019 - 07:42 AM

tried jquery also

i even went so far to make a static hidden field outside the grid just for a test and nope--- i think it has something to do with the code they have in this thing---- i believe the source code was outsourced --- big pile of garbage and hard to follow...
Was This Post Helpful? 0
  • +
  • -

#5 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15160
  • View blog
  • Posts: 60,694
  • Joined: 12-June 08

Re: why isnt my hidden field setting?

Posted 09 April 2019 - 07:49 AM

Oh this is that <stupid> dynamically created pile of awesome? :D hahahahaha..

I laugh, but in honestly I have an ajax function in one of my projects that sets a hidden field using that exact bit of jquery, but the fight was finding out what the rendered page called the hidden field since the jquery is operating on the rendered pile of crap.
Was This Post Helpful? 1
  • +
  • -

#6 DarenR   User is offline

  • D.I.C Lover

Reputation: 624
  • View blog
  • Posts: 4,165
  • Joined: 12-January 10

Re: why isnt my hidden field setting?

Posted 09 April 2019 - 09:03 AM

yeah i was having an issue with a date field and after doing an extremely slow debug on it-- i found that the code was setting the date to a non existent date--- i had to chop the code to force an ignore on the date since i didnt know where else it was being used and didnt feel like breaking all the code
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1