PHP Combo Box JQuery - Remove value on page load
I posted a similar question but this is slightly different. I need to scan all the text boxes on a page (there will be around 100, all with dynamic names in the form [ROW]) and then remove matching values from a drop down. I've played around with this a lot and a) can't get the windows.load function to fire in IE (Firefox is ok) but then can't get regular Javascript to match the text box value to the combo box option text.
I'm hoping someone can point me in the right direction with JQuery! The client is screaming in my ear to get this done!
thanks for that josh
this is the code I had for the init function the code isn't firing for IE but is for Firefox and doesn't match the text values of the text box and selection option text
<script type="text/javascript">
function init()
{
try
{
// quit if this function has already been called
if (arguments.callee.done) return;
// flag this function so we don't do the same thing twice
arguments.callee.done = true
var objPlayer = document.getElementById("player")开发者_如何学Python;
if(objPlayer == null)
{
alert("player list not found");
}
for(intPos = 0; intPos < 23; intPos++)
{
for(intChoice = 1; intChoice < 4; intChoice++)
{
var objText = intPos+"Year1Pick"+intChoice;
var obj = document.getElementById(objText);
if(obj)
{
for(var i = 0; i < objPlayer.options.count -1; i++)
{
if(obj.value == objPlayer.options[i].value)
{
alert("Found match !!! "+obj.value+" at poition "+intPos+" choice "+intChoice);
objPlayer.remove(i);
}
}
}
}
}
}
catch(e)
{
alert("The following error occurred: " + e.name + " - " +e.message);
}
};
/* for Mozilla */
if (document.addEventListener) {
document.addEventListener("DOMContentLoaded", init, false);
}
/* for Internet Explorer */
/*@cc_on @*/
/*@if (@_win32)
document.write("<script defer src=ie_onload.js><"+"/script>");
/*@end @*/
/* for other browsers */
window.onload = init;
</script>
Well, you didn't provide any code so all we can do is guess. But i believe you should use something like:
$('input:text').live('load', function(){$('select option[value="'+$(this).val()+'"]').remove() ;});
This will remove from the select all options with the same value as the one entered in a text input (when the text-input is loaded).
精彩评论