seventheyejosh Posted April 20, 2009 Share Posted April 20, 2009 ok basically i need to have a drop down that when someone chooses an app type the 1st time, it just ajaxs and writes to the div underneath it... but if they change the value of the dropdown afterwards, i need a prompt to come up, if they hit ok to change type, i need to empty the div and rewrite to it. i have all this working fine. my problem is that if they hit cancel, i need the dropdown to revert to its previous value, or just not change at all. a very simplified version of what i have now: function update(){ var r=confirm("Changing the app. type will erase all entered data."); if (r==true){ var ok=document.getElementById('that_select').value; var url='path.to.folder.that.holds.'+ok+'.tpl'; sndReqList(url); }else{ return false; } } and the html is simply: blah blah onChange="return update();" so if i do onclick it sends it right away, but if i do onchange the value is lost... thanks to anyone who attempts to help with this mess have a great day! Quote Link to comment Share on other sites More sharing options...
rhodesa Posted April 20, 2009 Share Posted April 20, 2009 <script> var lastSelection; function update(){ if(!lastSelection || confirm("Changing the app. type will erase all entered data.")){ var ok=document.getElementById('that_select').value; var url='path.to.folder.that.holds.'+ok+'.tpl'; sndReqList(url); lastSelection = document.getElementById('that_select').selectedIndex; }else{ document.getElementById('that_select').selectedIndex = lastSelection; } } function sndReqList(url){ alert(url); } </script> <select id="that_select" onchange="update()"> <option value="a">A</option> <option value="b">B</option> <option value="c">C</option> </select> this handles the "if it's the first change, just process it" case Quote Link to comment Share on other sites More sharing options...
seventheyejosh Posted April 20, 2009 Author Share Posted April 20, 2009 BEAUTIFUL! thank you so so so much Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.