bouncingHippo
bouncingHippo

Reputation: 6040

AJAX onchange behaviour changes after form submission

     <form   action="" name="theForm" method="post">

    ...code for dropdown menus initialized to empty...

    <td colspan="1" width="250">
      <input type="text" id="CAPS_CODE" name="CAPS_CODE" value=""  
        onchange="setF('LALA', this.value)" size="20" maxlength="20"/>

           <div style="display:none;" id="CAPS_CODE$err">

            <span style="color: #FF0000; font-family: Arial, 
              Helvetica, sans-serif; font-size: 10px; 
               font-weight: bold; text-decoration: none;">
            </span>
           </div>
    </td>

    `....form submit button in HTML and function call here - legacy code that works...`

    </form>

Basically this is an input textbox. When i enter 'BMW', and move the cursor click it outside the textbox, it will populate the dropdown menus to certain values. This is what i understand onchange does. I submit the form, and the page reloads.

Now, when i try entering new values into the textbox, such as entering A, the value keeps being deleted. And this occurs before i click outside the textbox. Is this got to do with after form submission?

NOTE: i am using AJAX as below in my JS function calls, if this is helpful..

var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, capsCallback, postData);    

function setF(group_id, caps){
        var token = document.theForm.sessionToken.value;
        getCarByAjax(token, group_id, caps);              
    }   


function getCarByAjax(sessionToken, group_id, caps){

        top.currentDependencyGroup = group_id;

        //alert("strs= " + strs);
        var entryPoint = '/DropDownList?';

        // entryPoint is the base URL
        if(top.ctx != null && top.ctx != ""){       
            entryPoint = top.ctx + '/DropDownList?';
        }

        var sUrl = entryPoint + encodeURI;

        var postData = 'CAPSVEH=' + caps + '&FROM=' + group_id + '&sessionToken=' + sessionToken;   
        var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, capsCallback, postData);            
    }

Upvotes: 1

Views: 462

Answers (1)

LaneLane
LaneLane

Reputation: 353

yeah solution is in your JS code. try onblur, or alerts in your JS code to debug. pay attention to display.style='none' and resetting values=''

Upvotes: 1

Related Questions