|
Ummmm, wake up. This thread is six months old.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
This is a piece of the code I'm working with and the only part giving me problems. I'm using the combo box to give me both the Line2_flag and the screencharge. Without this particular piece of code the form works fine so I know it's just this snippet. Any help is appreciated. Thanks!
<select name="inkcolors" size="1" id="inkcolors" class="FormStyle"
<option selected value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
var = Line2_flag;
var = screencharge;
if(form.inkcolors[1].selected){
Line2_flag = 1.75;
screencharge = 1;
}
if(form.inkcolors[2].selected){
Line2_flag = 2.25;
screencharge = 2;
}
if(form.inkcolors[3].selected){
Line2_flag = 2.75;
screencharge = 3;
}
|
|
|
|
|
You may like to explain what the problem is.
Veni, vidi, abiit domum
|
|
|
|
|
Sorry I wasn't clearer, but I did receive my answer on another site so I will post it here in case it helps.
<html>
<form>
<select name="inkcolors" size="1" id="inkcolors" class="FormStyle"
<option selected value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
</form>
<script>
var Line2_flag = null;
var screencharge = null;
var field = document.forms[0].elements['inkcolors'];
var selected = field.options[field.selectedIndex].value;
if (selected === "1") {
Line2_flag = 1.75;
screencharge = 1;
} else if (selected === "1") {
Line2_flag = 2.25;
screencharge = 2;
} if (selected === "3") {
Line2_flag = 2.75;
screencharge = 3;
}
</script>
</html>
|
|
|
|
|
All well and good but you still did not explain what the original problem actually was.
Veni, vidi, abiit domum
|
|
|
|
|
Are you sure this is right?
You're checking for selected === "1" a second time in the else if , so the middle section will never execute.
|
|
|
|
|
hello,
i am mahesh kadtan student of BE IT . for last yr project i`m developing "EDP management system" it has front end JSP and back end oracle 10g my source code run correctly on tomcat server, with the help of local host i.e loop back address. now my project guide told me to use 2 different PC one is for front end and another one is for back end BUT i have no clue how to connect two pc using connection string . i have basic knowledge i.e i have to put my IP instead of local host n so on. BUT full procedure how to set up client-server connection and how can i connect 2 different system using a connection string
here is my soure code:-
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
out.println("hello" );
Connection con = DriverManager.getConnection("jdbc:odbc:EDP","scott","tiger");
edp :- DSN name
scott:- DB username
tiger:- DB password
so plz post ur valuable commt with full procedure so that i can complete my BE project
with best regard
mahesh kadtan
|
|
|
|
|
If you're in your final year, you should have learned the difference between Java[^] and JavaScript by now. Aside from a vaguely similar syntax, there's no connection between the two.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
|
Hi guys. I do not know JS / AJAX / Web tech, I just need plain and simple mechanism for multiple files upload.
Currently I have this (taken from the net actually):
function uploader(place, targetPHP)
{
this.drop = function(event)
{
event.preventDefault();
var dt = event.dataTransfer;
var files = dt.files;
var progressBar = document.querySelector('progress');
for (var i = 0; i < files.length; i++)
{
var file = files[i];
xhr = new XMLHttpRequest();
xhr.open('POST', targetPHP, false);
xhr.setRequestHeader('UP-FILENAME', file.name);
xhr.setRequestHeader('UP-SIZE', file.size);
xhr.setRequestHeader('UP-TYPE', file.type);
xhr.onreadystatechange = function()
{
if(this.readyState == 4 && this.status == 200)
{
progressBar.value = Math.round((i * 100) / files.length);
}
}
xhr.send(file);
}
progressBar.value = 100;
setTimeout("location.reload(true);", 2000);
}
this.uploadPlace = document.getElementById(place);
this.uploadPlace.addEventListener("dragover", function(event)
{
event.stopPropagation();
event.preventDefault();
}, true);
this.uploadPlace.addEventListener("drop", this.drop, false);
}
This thing uploading files synchronously one by one but it makes a browser, such as IE for example, freezes. I need to modify
this script the way it will be doing same but asynchronously. So it will upload one file, then in onreadystatechange event
it will trigger next file upload. This is because my server is a 2 threaded application, which processes XMLHttpRequest one by one.
Basically, I got no idea how to modify this script that way because I do not know js / ajax at all.
I was trying to collect files into an array, which was a class member, and then process them but uploader just stopped
after first file upload.
Thanks in advance.
011011010110000101100011011010000110100101101110
0110010101110011
|
|
|
|
|
Responding to my own question but it seems like I was messing around with this keyword in an inappropriate way. Correct code for sequential async file uploader goes like this:
function XMLHttpUploader(place, targetPHP)
{
upload = function (currentArray, arrayTotalSize) {
var currentFile = currentArray.shift();
if (currentFile) {
var xhr = new XMLHttpRequest();
xhr.open('POST', targetPHP, true);
xhr.setRequestHeader('UP-FILENAME', currentFile.name);
xhr.setRequestHeader('UP-SIZE', currentFile.size);
xhr.setRequestHeader('UP-TYPE', currentFile.type);
xhr.onreadystatechange = function () {
if (this.readyState == 4 && this.status == 200) {
var progressBar = document.querySelector('progress');
if (progressBar) {
progressBar.value = Math.round(((arrayTotalSize - currentArray.length) * 100) / arrayTotalSize);
}
upload(currentArray, arrayTotalSize);
}
}
xhr.onerror = function () {
alert('File transfer failed!');
}
xhr.send(currentFile);
}
else {
var progressBar = document.querySelector('progress');
if (progressBar) {
progressBar.value = 100;
setTimeout("location.reload(true);", 2000);
}
}
}
this.drop = function(event)
{
event.preventDefault();
var currentArray = new Array();
for (var i = 0; i < event.dataTransfer.files.length; i++) {
currentArray.push(event.dataTransfer.files[i]);
}
upload(currentArray, currentArray.length);
}
this.uploadPlace = document.getElementById(place);
this.uploadPlace.addEventListener("dragover", function(event)
{
event.stopPropagation();
event.preventDefault();
}, true);
this.uploadPlace.addEventListener("drop", this.drop, false);
}
011011010110000101100011011010000110100101101110
0110010101110011
|
|
|
|
|
<script type="text/javascript">
function doClick(btnSearch, e) {
//the purpose of this function is to allow the enter key to
//point to the correct button to click.
var key;
if (window.event)
key = window.event.keyCode; //IE
else
key = e.which //firefox
if (key == 13) {
//Get the button the user wants to have clicked
//var btn = document.getElementById(<%=btnSearch.ClientID%>);
var btn = $get(btnSearch);
<%--var b = document.getElementById('<%=btnSearch.ClientID%>');--%>
if (btn != null) { //If we find the button click it
btn.click();
event.keyCode = 0
}
}
}
</script>
|
|
|
|
|
Where is the code that calls doClick?
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
without having to load the entire jQuery library, is there a way in straight JavaScript to restrict file upload to jpg and png and size to 200K? I understand I have to also make the checks on the server side, but why tax the server needlessly?
|
|
|
|
|
|
var str = "myfile.jpg";
var res = str.split(".");
if(res[1] == "jpg"){
return true;
}else{
return false;
}
|
|
|
|
|
In .net Project(Solution), Need to remove unused Javascript functions and variables from JS file.
In my project I'm having a lot of js file upto 40 files. I have to remove the unwanted code.
Need help to identify unused CSS (Cascading Style Sheet) lines.
Kindly share your ideas and expecting the solution asap.
|
|
|
|
|
|
I am having a dickens of a time getting a particular function to behave properly. This is client-side script. I find that I have to enclode the variable to be returned in parenthesis, or the function will not run at all. However, the calling routine chokes on the return and never gives the value passed back. WHY would I have to put parenthesis around the return variable (e.g., Return (VName);) in order for my function to run. WHAT am I doing wrong (I am new to JavaScript). Here is the code. I never get to the second alert.
function SetFund(){
alert('1');
var FundVal = GetFundValue();
alert('2');
}
function GetFundValue() {
var FundVal = '143';
var strRef = document.referrer;
if (strRef == '')
{
Return(FundVal);
}
else
{
strRef=strRef.replace('http://','');
strRef=strRef.replace('https://','');
var i =strRef.indexOf('/');
strRef=strRef.substr(i+1);
strRef=strRef.replace(new RegExp('/', 'g'),'');
strRef=strRef.replace(new RegExp('-', 'g'),'');
var FDID = GetDesigID();
var fdes = document.getElementById(FDID);
var strTmp=fdes.innerHTML.replace(new RegExp('<option value="', 'g'),'');
var strTmp=strTmp.replace(new RegExp('<option selected="selected" value="', 'g'),'');
var strTmp=strTmp.replace(new RegExp(' ', 'g'),'');
var strTmp=strTmp.replace(new RegExp(String.fromCharCode(9), 'g'),'');
var strTmp=strTmp.replace(new RegExp(String.fromCharCode(10), 'g'),'');
var strTmp=strTmp.replace(new RegExp('">', 'g'),',');
strTmp=strTmp.toLowerCase();
var strHTML = strTmp.split('</option>');
for(var i = 0; i < strHTML.length; i++)
{
var FundValuePair = strHTML[i].split(',');
if(FundValuePair[1].indexOf(strRef) > 0){
FundVal = FundValuePair[0];
Return(FundVal);
}
}
Return(FundVal);
}
}
|
|
|
|
|
Javascript is case-sensitive, and "return" should be in lower case.
By wrapping the value after "Return" in parentheses, you're turning it into a call to a function called "Return" that doesn't exist, which will throw an exception.
|
|
|
|
|
Graham:
Without the parentheses, the code does not even get entered. I put an "alert" at the very top of the function, and it never gets there. So I get it on not using parentheses on the Return statement. However, what else is wrong with the code that would make it non-functioning?
|
|
|
|
|
Without the parentheses, the code contains a syntax error - the parser will give up and not execute it.
With the parentheses, the parser will accept that you want to call a function called "Return" (assuming that it will be defined later) and only fail when you try to call it.
These errors are fairly easy to spot if you use your browser's development tools (or at least take a look at the Javascript console).
|
|
|
|
|
My problem is I have "Return" capitalized!! I do not have a smart javascript development environment. My editor catches no errors. I spent hours trying to figure out what was wrong. Argh!!
|
|
|
|
|
Which is exactly what Graham said[^] 6 hours ago.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|