I have an html select element that, based on a value set elsewhere, is supposed to show one of two pairs of value. In one case, it should be "New" and "Assumed", and in the other "Existing" and "Organic Growth"
So currently I'm creating it with all of them, like so:
It is not just that the REST method is not getting called - this handler is apparently not firing at all, as I see no alerts (neither "The button was clicked." nor "hey, boo-boo!").
The script *is* being added - I can step through it, and the vars (such as "unitval") *are* being assigned the appropriate values.
So why does clicking the button, which is declared like so:
<button class="btn green smallbutton" id="btnGetData" name="btnGetData">SUBMIT</button>
I want to append some html to an element; so far my failure is so catastrophic as to make Napoleon's battle at Waterloo seem like a roaring success by comparison. Before adding it to actual code, I tried fiddling around first with these variations on the theme, based on what I got from here, but it's not working. What am I missing/doing wrong?
The HTML from the fiddle is:
<h2>REPORTS TO BE GENERATED</h2>
<table style=\ "width:100%\">
<tr>
<th>Report Name</th>
<th>Unit</th>
<th>Generation Date</th>
<th>Data Begin Date</th>
<th>Data End Date</th>
<th>Recipients</th>
</tr>
<tr>
<td>Produce Usage</td>
<td>ABUELOS</td>
<td>5/11/2016</td>
<td>5/11/2016</td>
<td>sOMETHING</td>
<td>Something Else</td>
</tr>
</table>
<div id="fillme">
<label id="lbl">hey</label>
</div>
<iframe id="orme">
</iframe>
The Javascript from the fiddle is:
$( "#fillme" ).append( $( "<h2>REPORTS TO BE GENERATED</h2>" ) );
$( "#orme" ).append( $( "<h2>REPORTz TO BE GENERATED</h2>" ) );
$( "#orme" ).append( "<h2>REPORTz TO BE GENERATED</h2>" );
$( "th" ).append( $( "<h2>REPORTz TO BE GENERATED</h2>" ) );
$( "#lbl" ).append( $( "<h2>REPORTz TO BE GENERATED</h2>" ) );
<button class="btn pseudobtn darkgreentext" id="btnAddlEmail">+ Add Another Email</button>
</div>
</div>
However, there are two problems:
First, the "dialog" html I've added is not hidden - it displays at the bottom of the page. How can I hide it until the button is clicked?
Second, when I click #btnAddlEmail, it doesn't open a dialog next to the button, which is what I would hope, but simply "focuses" that div by paging down to it. How can I get that div to act like a dialog?
Note: I have done (presumably, anyway) what is necessary to make jQuery UI work in my project, following the steps here as discussed here.
Here is a scream shot of what it looks like ("+ Add Another Email" is what I click to show the dialog, which is laying lazily at the bottom):
This seems kind of white-glovish or even paranoid to me; is there a less obtrusive/verbose way of checking values for null than explicitly checking them all like this?
So stepping through the code, with a breakpoint in Chrom Dev Tools, I reach the "$.ajax({" line, but not the breakpoint in the Controller method (in Visual Studio), which has one on the last line shown below:
public class TestSettingsController : Controller
{
public JsonResult GetTestSettingVals(string unit, int RptID, string dayOfMonthGen, string ordinalGen, string dayOfWeekGen, string weekOrMonthGen, int fromIntDateRange, int toIntDateRange)
{
TestSettingsModel model = new TestSettingsModel();
I have other ajax/controller combinations designed the same way that work fine, so I can't see what the hangup is here...am I missing an either obvious or well-concealed problem here?
I need to select values from some html select elements based on what is passed back from an AJAX call. The data is being retrieved, but I can't seem to access the data so as to use it to set the html select elements to the appropriate value.
This is the html that describes the html selects that need to be manipulated:
contentType: 'application/json', //<= this is paired with stringify above; if comment out one, comment out both
cache: false,
success: function (returneddata) {
populategeneratevals(returneddata);
},
error: function () {
alert(returneddata.error.stringify);
}
});
function populategeneratevals(generatedata) {
// first, clear them all, if they had been set to something else
$("#dayofmonthselect").val('1st');
$("#ordinalselect").val('First');
$("#dayofweekselect").val('Monday');
$("#weekormonthselect").val('Month');
// Now set those for which there are values
//$("#dayofmonthselect").val(generatedata[0]); // doesn't work //$("#dayofmonthselect").val(generatedata.DayOfMonth); // doesn't work //$("#dayofmonthselect").val(generateddata.generatevals.DayOfMonth); - also doesn't work
$("#ordinalselect").val(generatedata[1]);
$("#dayofweekselect").val(generatedata[2]);
$("#weekormonthselect").val(generatedata[3]);
}
The second block of code in populategeneratevals() has no effect. I tried three different ways of accessing the "generatedata" data, but none of them changes the selected value of the "dayofmonthselect" element to what I want it to be - it DOES change it from a pre-selected value to nothing, though (changes from "1st" to nothing).
As mentioned, there *is* data; I can see this when stepping through it in ChromeDevTools:
So you can see "DayOfMonth" does have a value (5) in the case I'm testing. How can I extract the value that is there and use it to set the html-select val?
I've had nothing but trouble trying to download a file using simple HTML5, as is evidenced here on StackOverflow
It "sort of" works, but it seems unable or unwilling to identify the "App_Data" folder and its contents.
So, as I wonder aloud in Update 10 on that mega-post:
Maybe what I really need to do is, instead of the simple html, add some jQuery that will download the file. But the question is, can jQuery access the App_Data folder any better than raw/simple html can?
Is jQuery capable of downloading a file from a Web API app's App_Data folder to a user's file system from a web page? If the answer is "yes" do any of you have an example of how?
I have an HTML table here that, in the first column of "Shift
Details" in the "shift 1" section, has a "Hide
N" select element:
<TR>
<TD align="center"
valign="middle" rowspan="30">
some date
</TD>
<TD align="center"
valign="middle" rowspan="10">
shift 1
</TD>
<TD align="center"
valign="middle" >
<label>Hide </label>
<select id="hideselector">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
</select>
</TD>
Based on which option is selected, my jQuery hides labels below it,
which are defined this way:
<TD align="center"
valign="middle" >
<label id="jl1">job Loc 1</label>
</TD>
The quasi-Hobbesian jQuery is nasty and brutish, but unfortunately
not short:
$('#hideselector').change(function () {
$('#jl1').removeClass('hide');
$('#jl2').removeClass('hide');
$('#jl3').removeClass('hide');
$('#jl4').removeClass('hide');
$('#jl5').removeClass('hide');
$('#jl6').removeClass('hide');
$('#jl7').removeClass('hide');
$('#jl8').removeClass('hide');
$('#jl9').removeClass('hide');
var hidecount = $('#hideselector').val();
if (hidecount > 0) {
$('#jl1').addClass('hide');
}
if (hidecount > 1) {
$('#jl2').addClass('hide');
}
if (hidecount > 2) {
$('#jl3').addClass('hide');
}
if (hidecount > 3) {
$('#jl4').addClass('hide');
}
if (hidecount > 4) {
$('#jl5').addClass('hide');
}
if (hidecount > 5) {
$('#jl6').addClass('hide');
}
if (hidecount > 6) {
$('#jl7').addClass('hide');
}
if (hidecount > 7) {
$('#jl8').addClass('hide');
}
if (hidecount > 8) {
$('#jl9').addClass('hide');
}
});
It works, but I'm hoping there's a more concise/terse way
of accomplishing the same thing, especially since I will ultimately
need 84 very similar blocks of code (7 days X 3 Shifts X 4 Job
Locations per shift).
var d1s1jl1Count = $('date1Shift1JobLoc1Count').val();
if (d1s1jl1Count > 1) {
$('date1Shift1Worker5').removeClass('hide');
} else {
$('date1Shift1Worker5').addClass('hide');
}
}
..if date1Shift1Worker5 already had the class 'hide'
applied to it, would an additional 'hide' be added and, if so,
is that a problem other than maxifying the CSS?
I want to respond to a
right-click via checking "event.button == 2" like so:
"mousedown
#imgPostTravelBottom": function (event) {
if (event.button
== 2) {
$(
"#dialog" ).removeClass('hide');
$(
"#dialog" ).dialog();
}
},
...but although it works (the
dialog displays - in the middle of the page), so does the
browser's element-specific context menu; for example, when
right-clicking on an img, the browser invokes a context menu which
displays menu items such as "Save image as..." etc.
Can I suppress the displaying of
that context menu?
How can I get it to display elsewhere; specifically, with its NW
corner at the tip of the cursor (in the case where I invoke the
dialog on a right-click event)?
I had this code, which added inputted vals and put them in a
"totals" box:
'change .payments': function(event) {
var paymentTot = $('#paymenttotal').val();
paymentTot = parseInt(paymentTot) || 0;
var targetVal = $(event.target).val();
targetVal = parseInt(targetVal);
paymentTot = paymentTot + targetVal;
$('#paymenttotal').val(paymentTot);
},
...but then I realized I wanted "dollar amounts" and
interspersed what I hoped would convert the vals to floats (I naively
though that if one entered "2" it would get converted to
"2.00", etc.)
I have several input type="number" elements which, when
they change, should update a "total" element of the same
type. I gave all the input elements which should contribute to the
total the class "payments" like so:
...and then thought I could respond to a change in any element
with this class like so:
'change .payments' : function(event){
var
paymentTot = $('#paymenttotal').val();
paymentTot = paymentTot + this.val();
$('#paymenttotal').val(paymentTot);
}
It may look a little "weird" because it is in a Meteor
template method, but it works as far as responding when it should.
That is to say, this:
'change
.payments' : function(event){
console.log('something changed');
}
...caused that log entry to be made every time I changed the value
in any of the elements of that class. However, the code where I tried
to get the val from whichever element was being responded to in that
handler (I guessed -- wrongly, I reckon -- that I could refer to it as
"this"), fails. It gives me "Uncaught TypeError:
this.val is .... not a function"
How can I refer to whichever input is invoking the change event?
The problem is (besides that it doesn't work) is that it makes
browsers grumpy. When I run it in IE8, it says, when I select an item
from the first select element (ddlPaymentType1):
Webpage error details
User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1;
WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729;
.NET CLR 3.0.30729; .NET4.0C; .NET4.0E; InfoPath.3)
I have 5 rows that each have an identical selection element (or
dropDownList) in the first cell of each row. Choosing a value from
that populates the values in another selection element.
How can I populate the selection items, and in a way that is less
verbose than the "brute force" approach here:
$(document).on("change",
'[id$=ddlPaymentType1]', function () {
var value = $(this).val();
if (value == '1') {
$('[id$=ddlAccount1]').text("Replace this
with the values for selection 1");
}
else if (value == '2') {{
$('[id$=ddlAccount1]').text("Replace this
with the values for selection 2");
}
else if (value == '3') {{
$('[id$=ddlAccount1]').text("Replace this
with the values for selection 3");
}
else if (value == '4') {{
$('[id$=ddlAccount1]').text("Replace this
with the values for selection 4");
}
else if (value == '5') {{
$('[id$=ddlAccount1]').text("Replace this
with the values for selection 5");
}
else if (value == '6') {{
$('[id$=ddlAccount1]').text("Replace this
with the values for selection 6");
}
/* TODO: Add the rest (not value=11, as
that is the "VENDORS" category item (not a
real selection in itself)) */
});
With the above, I would have to respond to about 20 different
values (only six are shown), and I would have to code five
identical-except-for-the-ID-arg and val functions. IOW, I would also need
$(document).on("change",
'[id$=ddlPaymentType2]', function () {