After lurking for a while I figured I'd try to help a newbie out after
all the help I've gotten off this list.

I've found there's no need to search within a context if you've paid
attention to how you code your HTML.  I threw together the code below to
do what you were originally looking for.

<form name="form">
        <select name="select" class="selectsubmit">
                <option value="1">1</option>
                <option value="2">2</option>
                <option value="3">3</option>
                <option value="4">4</option>
                <option value="5">5</option>
        </select>
        <input type="submit" name="submit" value="submit" />
</form>

<script>
$(document).ready(function(){
        //Snag the select.selectform element
        $(".selectsubmit").each(function() {
                //Remove the submit button
                $(this).parent().find("[EMAIL PROTECTED]'submit']").remove();
                //Add a onChange event to the select.selectsubmit
                $(this).change(function() {
                        //Add a submit event to the form (found via
parent() )
                        $(this).parent().submit(function() {
                                //Now that the function is within the
context of the form, and not select.selectsubmit, we can use native JS
functions to submit the form
                                this.submit();
                        });
                        //Fire the submit event we just attached
                        $(this).parent().submit();
                });
        });
        
});
</script>

Now, while I was doing this, I got tripped up on how to submit() the
form onchange of the select.  The above code works in FF, but it seems
kinda cludgy and not very JQ-elegant.  Why do I have to add an event
then fire the event off?

I'm sure some guru will rewrite this in one line, but I wanted to give
it a stab.  Hope it helps.

-ALEX

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Truppe Steven
Sent: Wednesday, October 25, 2006 3:44 PM
To: jQuery Discussion.
Subject: [jQuery] again on question on selectors


Can someone tell me why this does not work ? I'm trying to remove the
submit button from a form (.selectsubmit = <select
class='selectsubmit'>)

$(document).ready(function(){
    $(".selectsubmit").each(function(){
        $("[EMAIL PROTECTED]", $(this)).remove();
    });
});

i thought i can search with for example $("div", context) inside a
specific context !?
Also if i try to submit the form with $(this).parent().submit() it does
not work =(

Can someone tell me what i do wrong ?

best regards,
Truppe Steven

_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to