This is a migrated thread and some comments may be shown as answers.

[Solved] get_value not working

2 Answers 252 Views
Input
This is a migrated thread and some comments may be shown as answers.
Baatezu
Top achievements
Rank 2
Baatezu asked on 15 Apr 2008, 02:41 AM
I'm getting an error of "[control].get_value is not a function". I've been trying to hunt down the proper javascript... but everything I've found suggests that the get_value should work.

<script type="text/javascript"
 function PreventPostback(sender, eventArgs) 
 { 
    var txtGrossCommission = document.getElementById('<%= radNumCommissionValue0.ClientID %>'); 
    var txtTypeValue = document.getElementById('<%= radNumCommissionValue.ClientID %>_text'); 
    var ddlType = document.getElementById('<%= radComboType.ClientID %>_ClientState'); 
    var txtCommission = document.getElementById('<%= radNumCommissionAmount.ClientID %>'); 
             
    var re1 = new RegExp(".+\"value\":\""); 
    var re2 = new RegExp("\",\"text\".+"); 
     
    var clientValue = ddlType.value.replace(re1, "").replace(re2, ""); 
 
    alert(sender.get_value()); 
    alert(txtGrossCommission.get_value()); 
 
    if(clientValue == "percent"
    { 
        txtCommission.set_value(txtGrossCommission.get_editValue() * txtTypeValue.get_editValue()/100); 
    } 
    else if(clientValue == "flatrate"
    { 
        txtCommission.set_value(txtTypeValue.get_editValue()); 
    } 
 } 
</script> 

The first alert works fine; the second alert fails. The Firefox Error Console gives me the error - "txtGrossCommission.get_value is not a function".

I'm obviously missing something - No idea what though. Any help would be great.

2 Answers, 1 is accepted

Sort by
0
Leon
Top achievements
Rank 1
answered on 15 Apr 2008, 06:44 AM
Use $find AJAX function to get control client object. Look at the ASP.NET AJAX docs or just ask Google for more info about the function.

var txtCommission = $find('<%= radNumCommissionAmount.ClientID %>');

-Leon
0
Baatezu
Top achievements
Rank 2
answered on 15 Apr 2008, 08:19 AM
Many Thanks - Fixed it perfectly.

I think I tried the $find earlier - but I musta had a few other things 'wrong' so it didn't solve it like it did this time.
Tags
Input
Asked by
Baatezu
Top achievements
Rank 2
Answers by
Leon
Top achievements
Rank 1
Baatezu
Top achievements
Rank 2
Share this question
or