I want to block NextButton not using disableNextButton Method in Qualtrics.
Qualtrics.SurveyEngine.addOnload(function() {
function myFunction() {
var c = confirm("JUST for TEST");
if (c == true) {
this.clickNextButton();
} else {
//I need your help :(
}
}
document.getElementById('NextButton').onclick = function() {
if(document.getElementById('NextButton').nodeName= "submit") {
myFunction();
}
};
});
Do you want your NextButton to be visible? If so, just use:
$('NextButton').disabled=true;
You can also hide it:
$('NextButton').hide();
What I've understood:
When the next button is pressed, you want to check if a particular condition is met or not.
If the condition is met you want the next button to work as is.
If the condition doesn't meet you want to prevent the click's functionality.
Solution: Try using event.preventDefault() when the condition doesn't meet.
You need not write this.clickNextButton(). That is triggered by default.
Related
I have a grid with a "change" function which gets fired every time a row is selected or when I click edit/delete/update/cancel button.
What I want is to have an ability to tell the difference, because I only what to execute certain code when a row is selected, and not execute it when I am doing cruds or a row.
change: function(e) {
// Body of the function...
IF ROW IS SELECTED
EXECUTE CODE
ELSE IF ROW IS DELETED, EDITED, ETC.
DO NOTHING
END IF
}
Is there a way to tell the difference inside the "change" function?
You can use the "action" property from the event data:
function onChange(e) {
if(e.action == "itemchange") {
//update
} else if (e.action == "add") {
//add
} else {
//delete
}
}
Currently you only need one checkbox to be checked in order to activate the button. I would like to make it so 3 of the checkmarks need to be checked in order to activate.
http://jsfiddle.net/chriscoyier/BPhZe/76/
var checkboxes = $("input[type='checkbox']"),
submitButt = $("input[type='submit']");
checkboxes.click(function() {
submitButt.attr("disabled", !checkboxes.is(":checked"));
});
Here you go! The issue is you should use the ":not()" selector.
http://jsfiddle.net/douglasloyo/BPhZe/470/
var checkboxes = $("input[type='checkbox']"),
submitButt = $("input[type='submit']");
checkboxes.click(function() {
submitButt.attr("disabled", checkboxes.is(":not(:checked")));
});
You can count how many checkboxes are set using:
var numChecked = $("input[type='checkbox']:checked").length;
Here's a fiddle: http://jsfiddle.net/9whF5/ Change the condition if you want at least three boxes to be checked. As is, the fiddle requires exactly three boxes to be checked.
Here you go. It even disables if the third is unchecked.
Here's the working fiddle: http://jsfiddle.net/BPhZe/471/
var checkboxes = $("input[type='checkbox']"),
submitButt = $("input[type='submit']");
checkboxes.click(function() {
if ($(":checkbox:checked").length >= 3){
submitButt.attr("disabled", false);
}
else{
submitButt.attr("disabled", true);
}
});
i have a gridview which contains a linkbutton with a ID LnkCourseName
i have requirement that on a click of Middle button of a mouse a new tab should open.
to check the which button of a mouse got clicked, i used a javascript function as :
<script type="text/javascript">
function buttonalert(event) {
var button;
if (event.which == null)
button = (event.button < 2) ? leftclickclear() :
((event.button == 4) ? middleclickclear() : rightclickclear());
else
button = (event.which < 2) ? leftclickclear() :
((event.which == 2) ? middleclickclear() : rightclickclear());
dont(event);
}
function leftclickclear() {
$('#<%=HdUrl.ClientID %>').val("left");
}
function rightclickclear() {
$('#<%=HdUrl.ClientID %>').val("right");
}
function middleclickclear() {
$('#<%=HdUrl.ClientID %>').val("middle");
}
function dont(event) {
if (event.preventDefault)
event.preventDefault();
else
event.returnValue = false;
}
</script>
But on a press of a middle button i get an error
javascript:__doPostBack('dnn$ctr538$ViewTC_TakeAClass$GrdCourseDetail$ctl02$LnkCourseName','')
on a new tab url. Thanks for assistance.
This should be standard behaviour for any reasonable browser, and isn't really an ASP.NET or script issue - the problem is that you're using a link button, which will do a postback just like a button (i.e. <input type=submit>), and it's not a link as in an default a element.
If your links are really just that, and are not expected to post back to the server to execute some logic, and instead just specifies a URL to link to, then use a HyperLink control instead.
This should be trivial, but I can't seem to figure out a way to do this.
I have a DataGrid, and what I would like to do, is when a user clicks on a row to select it, check a certain condition, and if it's met prevent the row from getting selected and keep the old selection intact.
Thanks!
I didn't test it, but it should work using event.preventDefault() and/or event.stopImmediatePropagation() on the GridSelectionEvent.SELECTION_CHANGING event.
//stupid function but used for example purpose
private function addListener():void
{
dataGrid.addEventListener(GridSelectionEvent.SELECTION_CHANGING, onSelectionChanging)
}
private function onSelectionChanging(event:GridSelectionEvent):void
{
if(!canRowBeSelected(event.selectionChange.rowIndex))
{
event.stopImmediatePropagation();
event.preventDefault();
}
}
private function canRowBeSelected(index:int):Boolean
{
//add logic
return false;
}
I have a page with a button and when it is clicked, it will execute a long time task asynchronously. I tried to implement validation on that button using javascript and a confirmation dialog box will pop up when it is clicked. But when i clicked on 'Cancel' in the confirmation dialog box, the long time task still will be executed instead of returning false.
Any idea guys? Any help is appreciated!
Code-Behind:
btnPrint.Attributes.Add("onclick", "javascript:submittingID='btnAdd';return validation();")
Public Sub LongTimeTask()
.......
End Sub
Javascript:
function validation() {
....
confirmPrint()
}
function confirmPrint() {
if (confirm("Are you sure you want to print? This process may take up to few minutes.") == true)
return true;
else
return false;
}
validation doesn't return anything. try:
function validation() {
//...
return confirmPrint();
}
You can also remove the if from confirmPrint. Doesn't change the behavior, but no need to check for true and return true:
function confirmPrint() {
return confirm("Are you sure you want to print?");
}
My guess from the description you gave is something like this:
Link Text