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

update value in textboxes

2 Answers 68 Views
Input
This is a migrated thread and some comments may be shown as answers.
Anumeha
Top achievements
Rank 1
Anumeha asked on 24 Sep 2010, 12:51 AM
Hi,
I have multiple textboxes on my page to maintain the order of a list.
I have a scenario where the user may delete the value in one of the text boxes and I want to update all the corresponding textboxes that follow the order.

So supoose I have 10 textboxes with the numbers 1 to 10. if the user deletes the text from the box with number 5 i want to update the text in the textboxes which follow 5 ie, through 6 -10 with the number 5-9.

Does this make sense?

Please let me know if this can be done?

2 Answers, 1 is accepted

Sort by
0
Anumeha
Top achievements
Rank 1
answered on 24 Sep 2010, 02:25 AM
Update:
 I got it to work by finding the controls in javascript and doing a get_value/set_value

However, it only works correct as long as I am updating the last value in the series. I have specified a onvaluechanged event on all my textboxes, so as soon as it updates one textbox it again calls the function for the newly updated textbox and that is when all my values get messed up.

I only want to call it once for the textbox user has updated and do not want to call it implicitly. How can i stop the onvaluechanged event to fire for the textboxes that are being changed by the code?

Here's the code i am using:
function ClientValueChanged(sender, args) {
                var newValue = args.get_newValue();
                var oldValue = args.get_oldValue();
                var textboxID = sender.get_id();
                var hiddenDiv = document.getElementById("<%=HiddenFieldOrder.ClientID %>");
  
                var cbID = textboxID.replace("RadTextBox", "CheckBox");
                var checkboxID = cbID.replace("Order", "");
  
                if (checkboxID.indexOf("Subject") < 0 && checkboxID.indexOf("StartTime") < 0) {
                    var chkbox = document.getElementById(checkboxID);
  
  
                    if (newValue == "") {
                        chkbox.checked = false;
                    }
                    else {
                        chkbox.checked = true;
                    }
                }
  
                var companyOrder = $find("<%=RadTextBoxCompanyOrder.ClientID %>");
                if (companyOrder.get_value() > oldValue) {
                    companyOrder.set_value(companyOrder.get_value() - 1)
                }
                else if (companyOrder.get_value() <= newValue && companyOrder.get_value() != "") {
                    companyOrder.set_value(companyOrder.get_value() - 1)
                }
  
                var contactOrder = $find("<%=RadTextBoxContactNameOrder.ClientID %>");
                if (contactOrder.get_value() > oldValue) {
                    contactOrder.set_value(contactOrder.get_value() - 1)
                }
                else if (contactOrder.get_value() <= newValue && companyOrder.get_value() != "") {
                contactOrder.set_value(contactOrder.get_value() - 1)
                }
  
                var descOrder = $find("<%=RadTextBoxDescriptionOrder.ClientID %>");
                if (descOrder.get_value() > oldValue) {
                    descOrder.set_value(descOrder.get_value() - 1)
                }
                else if (descOrder.get_value() <= newValue && companyOrder.get_value() != "") {
                descOrder.set_value(descOrder.get_value() - 1)
                }
  
                var duedateOrder = $find("<%=RadTextBoxDueDateOrder.ClientID %>");
                if (duedateOrder.get_value() > oldValue) {
                    duedateOrder.set_value(duedateOrder.get_value() - 1)
                }
                else if (duedateOrder.get_value() <= newValue && companyOrder.get_value() != "") {
                duedateOrder.set_value(duedateOrder.get_value() - 1)
                }
  
                var phoneOrder = $find("<%=RadTextBoxPhoneOrder.ClientID %>");
                if (phoneOrder.get_value() > oldValue) {
                    phoneOrder.set_value(phoneOrder.get_value() - 1)
                }
                else if (phoneOrder.get_value() <= newValue && companyOrder.get_value() != "") {
                phoneOrder.set_value(phoneOrder.get_value() - 1)
                }
  
                var keywordsOrder = $find("<%=RadTextBoxKeywordsOrder.ClientID %>");
                if (keywordsOrder.get_value() > oldValue) {
                    keywordsOrder.set_value(keywordsOrder.get_value() - 1)
                }
                else if (keywordsOrder.get_value() <= newValue && companyOrder.get_value() != "") {
                keywordsOrder.set_value(keywordsOrder.get_value() - 1)
                }
  
                var smartpadOrder = $find("<%=RadTextBoxSmartPadNoteOrder.ClientID %>");
                if (companyOrder.get_value() > oldValue) {
                    companyOrder.set_value(companyOrder.get_value() - 1)
                }
                else if (smartpadOrder.get_value() <= newValue && companyOrder.get_value() != "") {
                smartpadOrder.set_value(smartpadOrder.get_value() - 1)
                }
  
                var locationOrder = $find("<%=RadTextBoxLocationOrder.ClientID %>");
                if (locationOrder.get_value() > oldValue) {
                    locationOrder.set_value(locationOrder.get_value() - 1)
                }
                else if (locationOrder.get_value() <= newValue && companyOrder.get_value() != "") {
                locationOrder.set_value(locationOrder.get_value() - 1)
                }
  
                var participantsOrder = $find("<%=RadTextBoxParticipantsOrder.ClientID %>");
                if (participantsOrder.get_value() > oldValue) {
                    participantsOrder.set_value(participantsOrder.get_value() - 1)
                }
                else if (participantsOrder.get_value() <= newValue && companyOrder.get_value() != "") {
                participantsOrder.set_value(participantsOrder.get_value() - 1)
                }
  
                var perCompleteOrder = $find("<%=RadTextBoxPercentageCompleteOrder.ClientID %>");
                if (perCompleteOrder.get_value() > oldValue) {
                    perCompleteOrder.set_value(perCompleteOrder.get_value() - 1)
                }
                else if (perCompleteOrder.get_value() <= newValue && companyOrder.get_value() != "") {
                perCompleteOrder.set_value(perCompleteOrder.get_value() - 1)
                }
  
                var priorityOrder = $find("<%=RadTextBoxPriorityOrder.ClientID %>");
                if (priorityOrder.get_value() > oldValue) {
                    priorityOrder.set_value(priorityOrder.get_value() - 1)
                }
                else if (priorityOrder.get_value() <= newValue && companyOrder.get_value() != "") {
                priorityOrder.set_value(priorityOrder.get_value() - 1)
                }
  
                var subTypeOrder = $find("<%=RadTextBoxSubTypeOrder.ClientID %>");
                if (subTypeOrder.get_value() > oldValue) {
                    subTypeOrder.set_value(subTypeOrder.get_value() - 1)
                }
                else if (companyOrder.get_value() <= newValue && companyOrder.get_value() != "") {
                    companyOrder.set_value(companyOrder.get_value() - 1)
                }
  
                var statusOrder = $find("<%=RadTextBoxStatusOrder.ClientID %>");
                if (statusOrder.get_value() > oldValue) {
                    statusOrder.set_value(statusOrder.get_value() - 1)
                }
                else if (statusOrder.get_value() <= newValue && companyOrder.get_value() != "") {
                statusOrder.set_value(statusOrder.get_value() - 1)
                }
  
                var subjectOrder = $find("<%=RadTextBoxSubjectOrder.ClientID %>");
                if (subjectOrder.get_value() > oldValue) {
                    subjectOrder.set_value(subjectOrder.get_value() - 1)
                }
                else if (subjectOrder.get_value() <= newValue && companyOrder.get_value() != "") {
                subjectOrder.set_value(subjectOrder.get_value() - 1)
                }
  
                var timeOrder = $find("<%=RadTextBoxStartTimeOrder.ClientID %>");
                if (timeOrder.get_value() > oldValue) {
                    timeOrder.set_value(timeOrder.get_value() - 1)
                }
                else if (timeOrder.get_value() <= newValue && companyOrder.get_value() != "") {
                    timeOrder.set_value(timeOrder.get_value() - 1)
                }
  
                var timeSpentOrder = $find("<%=RadTextBoxTimeSpentOrder.ClientID %>");
                if (timeSpentOrder.get_value() > oldValue) {
                    timeSpentOrder.set_value(timeSpentOrder.get_value() - 1)
                }
                else if (timeSpentOrder.get_value() <= newValue && companyOrder.get_value() != "") {
                    timeSpentOrder.set_value(timeSpentOrder.get_value() - 1)
                }
                  
                var typeOrder = $find("<%=RadTextBoxTypeOrder.ClientID %>");
                if (typeOrder.get_value() > oldValue) {
                    typeOrder.set_value(typeOrder.get_value() - 1)
                }
                else if (typeOrder.get_value() <= newValue && companyOrder.get_value() != "") {
                    typeOrder.set_value(typeOrder.get_value() - 1)
                }
  
                hiddenDiv.value = oldValue;
            }



Please help!
0
Dimo
Telerik team
answered on 28 Sep 2010, 09:35 AM
Hi Anumeha,

As far as I can see, you have entered a vicious circle. You can use

textboxObject._SetValue(newValue)

instead of

textboxObject.set_value(newValue)

to set values without triggering the ValueChanged client handler.

Alternatively, you can use some global Javascript variables as flags in order to determine when to execute the ValueChanged handlers.

Kind regards,
Dimo
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Input
Asked by
Anumeha
Top achievements
Rank 1
Answers by
Anumeha
Top achievements
Rank 1
Dimo
Telerik team
Share this question
or