As everyone knows, that default button doesn't work in FF, only IE. I've tried to put in the tag or in the and it's not working. I've found a js script to fix this issue, but for some reason it's not working for me. This script for a submit button, i need to use it for a LinkButton, which is should be the same.
Link:
<div id="pnl">
<a id="ctl00_cphMain_lbLogin" title="Click Here to LogIn" href="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$cphMain$lbLogin", "", true, "Login1", "", false, true))">Log In</a>
<input name="ctl00$cphMain$UserName" type="text" id="ctl00_cphMain_UserName" />
<input name="ctl00$cphMain$UserName" type="text" id="ctl00_cphMain_UserName1" />
</div>
<script>
$(document).ready(function() {
$("#pnl").keypress(function(e) {
if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) {
$("a[id$='_lbLogin']").click();
return true;
}
});
});
I know that i can override original function "WebForm_FireDefaultButton"
in This post, but i really wanted to get this one to work.
Thanx in advance!!!
I found the answer to fixing linkbuttons here: http://www.sentia.com.au/2009/03/fixing-the-enter-key-in-aspnet-with-jquery/
$(document).ready(function(){
var $btn = $('.form_submit');
var $form = $btn.parents('.form');
$form.keypress(function(e){
if (e.which == 13 && e.target.type != 'textarea') {
if ($btn[0].type == 'submit')
$btn[0].click();
else
eval($btn[0].href);
return false;
}
});
});
Inspired by Larry Flewwelling's answer or rather Michael Cindric's, I came up with a modified and updated version of that javascript snippet. I've documented more detailed information on why and how in this blog post, but let me summarize the important changes:
Works with dynamically loaded content
Works with any number of "forms" on the same page
And here it is:
$('body')
.off('keypress.enter')
.on('keypress.enter', function (e) {
if (e.which == 13 && e.target.type != 'textarea') {
var $btn = $(e.target).closest('.jq-form').find('.jq-form-submit');
if ($btn.length > 0) {
if ($btn[0].type == 'submit') {
$btn[0].click();
}
else {
eval($btn[0].href);
}
return false;
}
}
});
You could expand your selector.
$("#pnl > input")
Which will then catch the input click for all the controls in the panel.
Related
I am doing a school project that need to use jsoup to scrape some datas from certain website.
I saw a button as following attribute:
<a rel="nofollow"
onclick="getRedirectPage(37443499,2206,801)"
class="showtime_btn btn btn-default seat_3"
id="37443499"
href="javascript:void(0)" role="button">06:40PM
<br>
<small>IMAX 3D</small
></a>
//below is the getRedirect method. I was trying to understand it,
but I dont know what language they using, have no idea where to learn the necessary knowledge to understand it, please help me out.
thank you !!
var timeout = "";
function clickRedirect(){
ga('send', 'event', 'Redirect_CTA', 'click', viewModel.popupRedirectAdsEventName());
}
function getRedirectPage(shid, movieid, cinemaid){
$('#page-overlay').show();
ga('send', 'event', 'Movie_SelectShowtime', 'click_showtime', movieid, cinemaid);
$.get("https://www.popcorn.app/sg/showtime/redirect",
{
showtimeid: shid
},
function (data){
setTimeout(function(){
$('#page-overlay').fadeOut();
},100);
var dt = JSON.parse(data);
if(dt.status > 0){
dt = dt.data;
viewModel.popupRedirectToLang(dt.lang_redirectto.replace('%s', dt.site));
viewModel.popupDisclaimer(dt.lang_disclaimer);
if(dt.redirect_ads != undefined && dt.redirect_ads.event_name != undefined){
viewModel.isExternalTraffic(true);
viewModel.popupRedirectAdsUrl(dt.redirect_ads.url);
viewModel.popupRedirectAdsLabel(dt.redirect_ads.label);
viewModel.popupRedirectAdsEventName(dt.redirect_ads.event_name);
}else{
viewModel.isExternalTraffic(false);
}
viewModel.popupRedirectNote(dt.lang_redirectnote);
viewModel.popupFollowUrl(dt.follow);
viewModel.popupLangBtn(dt.lang_btn_txt);
viewModel.targetBlank("_blank");
//campaign:
if(dt.campaigns != undefined && dt.campaigns.trackingUrl != undefined){
viewModel.isCampaignValid(true);
viewModel.adImage(dt.campaigns.adImage);
viewModel.campaignName(dt.campaigns.campaignName);
viewModel.isSmallerFont(dt.campaigns.isSmallerFont);
viewModel.campaignPercentage(dt.campaigns.campaignPercentage);
viewModel.companyName(dt.campaigns.companyName);
viewModel.campaignAddress(dt.campaigns.campaignAddress);
viewModel.campaignTrackingUrl(dt.campaigns.trackingUrl);
viewModel.discountedPrice(dt.campaigns.discountedPrice);
viewModel.originalPrice(dt.campaigns.originalPrice);
}else{
viewModel.isCampaignValid(false);
}
$("#redirectPopupTarget").show();
$(".close_btn").click(function(){
clearTimeout(timeout);
$("#redirectPopupTarget").hide();
});
timeout = setTimeout(function(){
window.location.href = dt.follow;
},5000);
}
})
.error(function (er) {
console.log("Error:", er.responseText);
});
}
$(document).ready(function(){
$("#redirectPopupTarget").css('height', $(window).height());
});
enter image description here
below link is the id = redirectPopupTarget
This is javascript with jQuery. This code does some other things, but I think you are most interested in getting redirect link.
This is done by sending request to https://www.popcorn.app/sg/showtime/redirect?showtimeid=shid. Where shid is first parameter of you javascript function (https://www.popcorn.app/sg/showtime/redirect?showtimeid=37443499).
The response to this request is in form of JSON and element you are looking for is in the field follow
In my rmarkdown document, I am able to show and hide code with the following - which creates a convenient button on the righthand side of the document before each block of code:
output:
html_document:
code_folding: hide
Is there a similarly convenient method to hide tables or figures? If so, please provide a reference as I have not been able to find any. Otherwise a workaround would be appreciated, thank you!
I have not been able to get the above solution (or others I found) to work consistently, but using the in-line html (Bootstrap example/solution) I found at W3schools.com works well in Rmarkdown.
I use it to show a simple plot in html output in the example below. It should work with any chunk output:
<button class="btn btn-primary" data-toggle="collapse" data-target="#BlockName"> Show/Hide </button>
<div id="BlockName" class="collapse">
```{r}
plot(mtcars$disp, mtcars$mpg)
```
</div>
note: If you use this on multiple sections, each one needs a unique id (ie replace BlockName with a unique id for each section to be collapsed.)
If you add this to the end of your .Rmd file
<script>
$( "input.hideshow" ).each( function ( index, button ) {
button.value = 'Hide Output';
$( button ).click( function () {
var target = this.nextSibling ? this : this.parentNode;
target = target.nextSibling.nextSibling.nextSibling.nextSibling;
if ( target.style.display == 'block' || target.style.display == '' ) {
target.style.display = 'none';
this.value = 'Show Output';
} else {
target.style.display = 'block';
this.value = 'Hide Output';
}
} );
} );
</script>
and then this before each chunk you want to have a toggle:
<input type=button class=hideshow></input>
(adapted from here: https://groups.google.com/forum/#!topic/knitr/d37E0mP3w6k)
Note: this will work if you show the code - if you are hiding the code (with echo = FALSE), change
target = target.nextSibling.nextSibling.nextSibling.nextSibling;
to
target = target.nextSibling.nextSibling;
Note 2: if you want to use the code_folding option, change
target = target.nextSibling.nextSibling.nextSibling.nextSibling;
to
target = target.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling;
I was able to get Lucy's code working for me, but I also think it's more useful and cleaner to have the outputs hidden by default. It's a very simple addition. Just execute jquery that clicks all the "Hide Output" buttons upon rendering. My code looks like this:
<script>
$( "input.hideshow" ).each( function ( index, button ) {
button.value = 'Hide Output';
$( button ).click( function () {
var target = this.nextSibling ? this : this.parentNode;
target = target.nextSibling.nextSibling;
if ( target.style.display == 'block' || target.style.display == '' ) {
target.style.display = 'none';
this.value = 'Show Output';
} else {
target.style.display = 'block';
this.value = 'Hide Output';
}
} );
} );
$("input.hideshow").click()
</script>
Only the last line before </script> was the addition.
Heyy so I changed the code of gclarkjr5 to have the table shown without being formatted.
It will show the hidden button first and not modify the display of the table.
So here goes:
Put this before the chunk you want to display:
<input type=button class=hideshow></input>
And then at the end of your markdown file:
<script>
$( "input.hideshow" ).each( function ( index, button ) {
button.value = 'Show Output';
$( button ).click( function () {
var target = this.nextSibling ? this : this.parentNode;
target = target.nextSibling.nextSibling;
if ( target.style.display == 'none') {
target.style.display = '';
this.value = 'Hide Output';
} else {
target.style.display = 'none';
this.value = 'Show Output';
}
} );
} );
$("input.hideshow").click()
</script>
I have a simple problem. I want to update my classes inside my inputs on form submit.
<div class="form-group">
<input class="form-control" ng-class="{'has-error': signup.$submitted && signup.name.$invalid}" type="text" name="name" ng-model="formData.name" required minlength="2" placeholder="Full Name">
</div>
Here's my app.js:
spinnrApp.controller('FormController', ['$scope', '$http', '$state', function (scope, http, state){
// get list of cities and store it to select
http.get('cities.json').success(function(data){
scope.cities = data;
})
// we will store all our form data in this object
scope.formData = {};
// function to process the form
scope.processForm = function(isValid) {
scope.$submitted = true;
if(isValid && state.$current=='registration.spinnrapp') {
state.go('registration.artist');
} else if(isValid && state.$current=='registration.artist') {
state.go('registration.share');
} else if(!isValid && state.$current=='registration.artist') {
alert('Please make sure you have selected an artist.');
} else if(!isValid && state.$current=='registration.spinnrapp') {
return;
}
};
}]);
When I execute my submit via ng-click calling this function, my signup.$submitted still stays as false. I also have a reference from this Plunker: http://plnkr.co/edit/xDIzC0A50cXxMpIHeP3C?p=preview
That Plunkr updates its class. Why isn't mine doing the same? Am I doing something wrong?
Iam trying to show/hide a div based on the radio button click in Yii form. But the onclick event is not working for me. Please help me to fix this as Iam a new bee to Yii.
Iam using this code for radio button
<?php echo $form->radioButtonList($model,'service_type',array(
'0'=>'Yes',
'1'=>'No',
'separator'=>'',
'onclick'=>"setVisible('Yes_box',true);setVisible('No_box', false)")); ?>
<div id="Yes_box" style="visibility: hidden"> contents of Yes type </div>
<div id="No_box" style="visibility: hidden"> contents of No type </div>
This is my script:
<script>
$(document).ready(function () {
$("input[name$='type']").click(function () {
var value = $(this).val();
if (value == 'Yes') {
$("#Yes_box").show();
$("#No_box").hide();
} else if (value == 'No') {
$("#No_box").show();
$("#Yes_box").hide();
}
});
$("#Yes_box").show();
$("#No_box").hide();
});
</script>
When Iam using this code only the last condition is working i.e, Yes_box is showing. I think the onclick value is not passing here. Please help me to recover this problem.
I thin your code is written correctly . only few changes / may be that will work .
I have edited the your code .Check this out :
<script>
$(document).ready(function () {
$("input[name=type]").click(function () {
var value = $(this).val();
if (value == 'Yes') {
$("#Yes_box").show();
$("#No_box").hide();
} else if (value == 'No') {
$("#No_box").show();
$("#Yes_box").hide();
}
});
});
</script>
Also NOTE :- check with an alert if you are able to get data into the value variable .
I want like this in javascript,when checkbox is visible show message1 else show message2.
Try this:
HTML:
<label><input type='checkbox' onchange='handleChange(this);'>Checkbox</label>
JS:
function handleChange(cb) {
if(cb.checked == true){
alert('Message 1');
}else{
alert('Message 2');
}
}
JSBIN:
http://jsbin.com/abukor/2
Hope this helps.
checkBox.onchange = function () {
console.log("Checked:" + checkBox.checked)
};
if($("#checkbox").is(":checked")){
alert("message1");
}else{
alert("message1");
}
You can use the javascript ternary operator
var msg = ($("#MyCheckbox").is(":checked")) ? 'message1' : 'message2';
alert(msg);
You could of course in-line the ternary to make it really compact
Also checkout this SO answer for some other examples of using the ternary operator.
If you want to show the message if the checkbox itself is visible then you can use the :visible operator which would make the code:
var msg = ($("#MyCheckbox").is(":visible")) ? 'message1' : 'message2';
alert(msg);