[RESOLVED] jquery alert Onclick
how can i put a alert on this
Code:
<input type="button" id="addlesson" value="Add Lesson!" onClick="inputter(document.getElementById('testid').value)" />
the onclick right now sends a value over the url
i want the alert to stop that and ask if they are sure they want to do that yes and continue no just stay there.
i have the jquery working but it doesn't stop the page from going on...
Code:
$(document).ready( function() {
$("#addlesson").click( function() {
jConfirm('Can you confirm this?', 'Confirmation Dialog');
});
});
how can i get the alert to tie into if the page action ?
Last edited by webevelopersFTW; 11-05-2009 at 02:56 PM .
How do i get an alert to stop a page from going on
Kinda a bump but lets see if anyone will help me out this time.
i have this button, i would like this button on click to pop up an alert "are you sure". If yes continue to the url that in the function, if no stay on the page.
Code:
<input type="button" id="addlesson" value="Add Lesson!" onClick="inputter(document.getElementById('testid').value)" />
here is the inputter function
Code:
function inputter(element){
parent.location='studentaddlesson.php?option=&s_id=' + escape(element);
}
$(document).ready(function() {
$('#testid').keyup(function(e) {
if(!e) e = window.event;
if(e.keyCode == 13) {
inputter(document.getElementById('testid').value);
}
}
)
} )
So my question is, how do i tie this jquery alert to the button to stop the action. Right now it pops up but does not stop the page from going to the url
Code:
$(document).ready( function() {
$("#addlesson").click( function() {
jConfirm('Can you confirm this?', 'Confirmation Dialog');
});
});
Please someone just point me in the right direction!
Thank you
CHeck if this helps.
Code:
$(document).ready( function() {
$("#addlesson").click( function() {
jConfirm('Can you confirm this?', 'Confirmation Dialog', function(r) {
if(r==true)
inputter(document.getElementById('testid').value);
});
});
});
and
Code:
<input type="button" id="addlesson" value="Add Lesson!" />
Keep in mind that one advantage of jquery is avoiding inline JS. If there are some typo's at least you know what I meant.
Thank you that works perfectly! I really appreciate the help!
how would you validate this?
Again i would like to click on this link and have a alert asking if i am sure.
following the same logic above how would i put an jquery alert on this?
Code:
<td bgcolor="#CDCDCD"><a href="studentdelete.php?s_id=<?php echo $row_rsDatabaseentry['s_id']; ?>">[Delete]</a></td>
It seemed to me you'll gonna do this with multiple rows? If that's the case I would rather go based on class.
Code:
<td bgcolor="#CDCDCD"><a class="deleteLink" href="studentdelete.php?s_id=<?php echo $row_rsDatabaseentry['s_id']; ?>">[Delete]</a></td>
and the jquery
Code:
$(".deleteLink").click(
function() {
jConfirm('Can you confirm this?', 'Confirmation Dialog', function(r) {
if(r==true)
<!-- Place your statement here, I'm not sure if this is the parameter you need but try if that's it $(this).attr("href");-->
});
});
you say in the jquery
<!-- Place your statement here, I'm not sure if this is the parameter you need but try if that's it $(this).attr("href");-->
what do i put there ? sorry i know its a very stupid question, but i cant seem to understand whats going on here.
yes you are correct i am doing this on multiple rows.
right now its going right through without the alert like before.
I *THINK* this is what you want
Code:
<td bgcolor="#CDCDCD"><a class="deleteLink" href="#" recordID="<?php echo $row_rsDatabaseentry['s_id']; ?>">[Delete]</a></td>
Code:
$(document).ready(
function(){
$(".deleteLink").click(
function() {
jConfirm('Can you confirm this?', 'Confirmation Dialog', function(r) {
if(r==true)
parent.location = "studentdelete.php?s_id=" + $(this).attr("recordID");
});
}
);
}
);
AGAIN, thank you! It works PERFECT!!
Last edited by webevelopersFTW; 11-06-2009 at 05:22 PM .
No worries. Don't forget to mark as resolved.
Sure no problem, but how do you do that?
Ok i am pretty stupid ... the alert works but it does not delete the entry (im stupid forgot to try that!) .Up in the url it says
Code:
index.php?s_id=undefined
it also says
Code:
index.php?s_id=undefined
when i hover over the link as well.
however i am trying to go to
Code:
studentdelete.php?s_id=
Last edited by webevelopersFTW; 11-06-2009 at 11:08 PM .
Make sure you have the html as follows
Code:
<td bgcolor="#CDCDCD"><a class="deleteLink" href="#" recordID="<?php echo $row_rsDatabaseentry['s_id']; ?>">[Delete]</a></td>
view the source as well and make sure you have a value for recordID. You can try to install FireBug as well if you're using FF. If the recordID have no value check your php.
before you asked me if
"
<!-- Place your statement here, I'm not sure if this is the parameter you need but try if that's it $(this).attr("href");--> "
this is where the codes stops working ... just a thought....
yes that's replaced by
Code:
parent.location = "studentdelete.php?s_id=" + $(this).attr("recordID");
What it does is get the attribute of the element that is named "recordID" and append it to the earlier string. The fact that it is undefined means that it was not set. Hence are you sure that you have the right value there. To do that either you check the source, use debugging tools like FireBug.
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Bookmarks