limitphp Posted February 9, 2009 Share Posted February 9, 2009 I use ajax on my main page. When a user clicks on "Add to Playlist" it calls an ajax function which makes a little box drop down underneath the "Add to Playlist" link. The box comes from the php page the ajax calls (add_playlist.php) Inside the box a user can click an "Add" button which is part of a form. What I want to happen, is when the user clicks "Add", I want it to submit the form and add the song to the playlist without leaving the main page. Unfortunately, what happens right now is, it leaves the main page and goes to the ajax page. There's probably a different way to go about what I want, i just don't know what it is. I'm still new to this stuff. Quote Link to comment Share on other sites More sharing options...
corbin Posted February 9, 2009 Share Posted February 9, 2009 <form action="blah" method="blah" onsubmit="return SomeFunction(this);"> </form> If SomeFunction returns false, the form will not submit. blah and blah would be used if onsubmit returned true. Or do you have a question about the actual AJAX parts? Quote Link to comment Share on other sites More sharing options...
limitphp Posted February 10, 2009 Author Share Posted February 10, 2009 <form action="blah" method="blah" onsubmit="return SomeFunction(this);"> </form> If SomeFunction returns false, the form will not submit. blah and blah would be used if onsubmit returned true. Or do you have a question about the actual AJAX parts? I'm not sure. What I want is, on the main page, when a user clicks "Add to Playlist" a box will come up that has some checkboxes with their existing playlists and a textbox where they can add a new one and an Add button. Once they select the playlists to add the song to, or type in a new one in the text box, they'll hit the Add button. What I want to happen then, is for the box to say Song has been added to playlist. And then they can click on an (x) or something where they can close the box. All the while the main page will stay open and not change. Right now, I use Ajax to open the box. What I think I'm going to have to do is use ajax again on the page that contains the box, that way when they click the Add button, it'll use ajax to add the song to the playlist, all while keeping the main page open. Quote Link to comment Share on other sites More sharing options...
corbin Posted February 11, 2009 Share Posted February 11, 2009 Yeah, that's what you'll have to do. 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.