best way to change download link based on an input field? - dynamic

I program in C (embedded programming) but have no experience for web-based stuff. I have a need to download a different link based on an input field.
input serial number in field.
click download link
if serial number = a,b,c etc.. download file_version_a
else if serial number = e,f,g, etc.. download file_version_b
what is the best script language to use to for something like this? I've searched all over and haven't found much that seems relevant and don't know where to start.

You could use something like below in your html page :
<input type="text" id="serialnumbers" name="serialnumbers"></input>
<input type="button" id="download" name="download" onclick="downloadlink();return false;"value="Download Now"></input>
<script>
function downloadlink(){
var serialnos=document.getElementById('serialnumbers').value;
serialnos = serialnos.trim();
if( serialnos == "a" || serialnos == "b" || serialnos == "c" )
window.location = download file_version_a;
}
else if( serialnos == "e" || serialnos == "f" || serialnos == "g" )
window.location = download file_version_b;
}
</script>
Also,some suggestions for the same would be to check Jquery,very convenient Javascript library ,Refer Doc :https://jquery.com/

Related

Razor-Pages - HTML markup

Following the answer on this post I was using #:<div class="col-md-6">
Problems
The Formatting gets all messed up:
The intellicode gets all messed up (I only deleted the paragraph on the second #:)
Also, my if (i == (Model.CellsNotStarted.Count - 1) && i % 2 != 0) won't work when using the #:; it will always go on the else. If I don't use the #: markup, and if I, for instance put all my html in a if/else instead of only the <div> tag it will work with no problems.
My question is:
Is the #: markup viable? If so, what am I doing wrong. If not what is the alternative (that does not imply putting my entire code in an if/else)
PS: I know I should not post images of code, but I wanted to show the format and syntax errors.
There are neater ways to manage conditions within your Razor code. It's difficult to provide a full example because you don't provide the full code, but you can do this, for example:
<div class="col-md-#(i+1 == Model.CellsNotStarted.Count && i % 2 ! = 0 ? "12" : "6")">
Whenever you are tempted to use a remainder operator (%) in Razor, you should also consider whether a GroupBy would be better. It most often is, as I was shown in this question: Building tables with WebMatrix
You can try to use js to set html.Here is a demo:
<div id="myDiv"></div>
<script>
$(function () {
var html = "";
if ("#(Model.CellsNotStarted != null)"=="True")
{
for (var i = 0; i <#Model.CellsNotStarted.Count; i++)
{
if (i == (#Model.CellsNotStarted.Count - 1) && i % 2 != 0)
{
html += '<div class="col-md-12">';
}
else
{
html += '<div class="col-md-6">';
}
html += i+'</div>';
}
}
$("#myDiv").html(html);
})
</script>
result:

I need a Tracking Pixel in vb.net

In php i fire off my pixel in a if statement like this :
if ($result == C){
echo "<img src='http://www.123123.com/tracking/RecordPixel.aspx?cmp=933&optional'/>";
}else{
echo "<meta http-equiv=\"refresh\" content=\"0;URL='http://123123.co.uk/index.php/'\"> ";
}
I am trying to do this in vb.net and i am looking for resources and cannot find any.
In VB.NET you can add a server control to your page, as a literal control. And in codebehind (for ex. in pageload), you can translate it in something similar to:
if (result = C) then
yourLiteralID.text = "<img src..."
else
yourLiteralID.text = "<meta..."
end if

Kindle Silk browser having issues with keypress event?

I'm trying to restrict a text box to numeric entry only in a project using knockout.js and MVC.
I'm doing a data-bind on the keypress event to call a function from the VM that looks like this:
this.NumbersOnly = function (data,evt) {
var charCode = (evt.which) ? evt.which : event.keyCode
if (charCode > 31 && (charCode != 46 && (charCode < 48 || charCode > 57)))
return false;
return true;
}
This will allow only numbers and decimals in to the input text box. This works great in every browser I've tested except that I'm having issues in Kindle's Silk browser, as I can still type alpha characters in. If anyone has any ideas to get Silk to agree, please let me know!

Adobe 9 Check box required field

I've created reports in Adboe that have checkobxes and set then to required fields.
But when i click the submit button all fields but the check boxes are validated.
I.e
If i dont complete the required textbox field the report will not submit, but when i do and the required checkbox fields are not checked it still submits.
This only appears to be happening on Adobe 9
Any ideas?
Thanks
Sp
Here is a link to a test page
http://www.mediafire.com/?mnkmmlime2f
If you fill the text box with anything it will submit regardless of the check box status (which is also a required field)
I have figured it out.
Adobe Reader checkbox allows has a value (default "false") so when the form validates it sees the checkbox as having a value.
I've had to write some java to stop the form submitting if the checkbox has a null/False/false value
This works like a dream
Thanks for trying to help wit hthis post all
var f;
var Valid = "1";
for (var i = 0; i < this.numFields; i++)
{
f = this.getField(this.getNthFieldName(i));
if (f.type == 'checkbox')
{
if(f.required == true)
{
if(f.value == "false" || f.value == "False" || f.value == "null")
{
Valid = "0";
}
}
}
};
if(Valid == "1")
{
this.submitForm('');
}
else
{
app.alert("Please complete all required fields");
}

how to get BrowserManager play nice with SWFObject (Flex 3)

I need to get the URL of the HTML where the SWF is embedded. I found out that it should be a piece of cake with BrowserManager, but unfortunately I use SWFObject to embed swf in html! and BrowserManager doesn't like that!!
could someone help me with this?
cheers
You can do it by changing the history.js file
comment out these lines:;
/*
if (players.length == 0 || players[0].object == null) {
var tmp = document.getElementsByTagName('embed');
players = tmp;
}
*/
and these:
/*
if (player == null || player.object == null) {
player = document.getElementsByTagName('embed')[0];
}
*/
these will make them play nicely together :-)