|
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
|
|
|
|
|
|
Javascript is case-sensitive, and "return" should be in lower case.
"Return(FundVal)" should be written by "return FundVal"
|
|
|
|
|
I've got ten questions here. All questions have two possible answers but only one is correct and I would like to know how to make the answer appear underneath its question after the submit button is pressed. Also sorry if you find some of the questions offensive but that's the kind of demographic I'm trying to reach out to. Anyway here's the code:
<p class="question">1.Would you rather be 2 foot tall or 10 foot tall?</p>
<input id="q1a" type="radio" name="q1" value="a" /><label for="q1a"> 2 foot tall</label>
<input id="q1b" type="radio" name="q1" value="b" /><label for="q1b"> 10 foot tall</label>
<p class="question">2.Would you rather be blind or deaf?</p>
<input id="q2a" type="radio" name="q2" value="a" /><label for="q2a"> Blind</label>
<input id="q2b" type="radio" name="q2" value="b" /><label for="q2b"> Deaf</label>
<p class="question">3.Would you rather be poor and work at a job you love or be rich and work at a job you hate?</p>
<input id="q3a" type="radio" name="q3" value="a" /><label for="q3a"> Poor and love my job</label>
<input id="q3b" type="radio" name="q3" value="b" /><label for="q3b"> Rich and hate your job</label>
<p class="question">4.Would you rather be homeless and have family and friends or not be homeless and live without family?</p>
<input id="q4a" type="radio" name="q4" value="a" /><label for="q4a"> Homeless with family and friends</label>
<input id="q4b" type="radio" name="q4" value="b" /><label for="q4b"> Not homeless without family and friends</label>
<p class="question">5.Would you rather have no legs or no arms?</p>
<input id="q5a" type="radio" name="q5" value="a" /><label for="q5a"> No legs</label>
<input id="q5b" type="radio" name="q5" value="b" /><label for="q5b"> No arms</label>
<p class="question">6.Would you rather have a vagina on your forehead or a penis on your belly-button?</p>
<input id="q6a" type="radio" name="q6" value="a" /><label for="q6a"> Vagina on my forehead</label>
<input id="q6b" type="radio" name="q6" value="b" /><label for="q6b"> Penis on my belly-button</label>
<p class="question">7.Would you rather molest a penguin and nobody knows or not molest a penguin and everyone thinks that you have?</p>
<input id="q7a" type="radio" name="q7" value="a" /><label for="q7a"> Do it and nobody knows</label>
<input id="q7b" type="radio" name="q7" value="b" /><label for="q7b"> Everybody just thinks that you did</label>
<p class="question">8.Would you rather be absolutely freezing, naked, in Antarctica or wear a snowsuit in the desert?</p>
<input id="q8a" type="radio" name="q8" value="a" /><label for="q8a"> Naked in the Antarctica</label>
<input id="q8b" type="radio" name="q8" value="b" /><label for="q8b"> Snowsuit in the desert</label>
<p class="question">9.Would you rather count all the grains of sand on a beach or watch paint dry for 1 hour everyday for the next 10 years?.</p>
<input id="q9a" type="radio" name="q9" value="a" /><label for="q9a"> Count all grains of sand on a beach</label>
<input id="q9b" type="radio" name="q9" value="b" /><label for="q9b"> Watch paint dry everyday for the next 10 years</label>
<p class="question">10.Would you rather have all farts be silent but extremely deadly, it all farts be harmless but extremely loud?</p>
<input id="q10a" type="radio" name="q10" value="a" /><label for="q10a"> Silent but deadly</label>
<input id="q10b" type="radio" name="q10" value="b" /><label for="q10b"> Loud but harmless</label>
<div id="results">Get Answers!</div>
<div id="category1">
<strong>Question 1:</strong> The correct answer is 10 foot because being 10 foot is 5 times better than being 2 foot tall.
</div>
<div id="category2">
<strong>Question 2:</strong> The correct answer is deaf because if you can't see people could be doing anything to you.
</div>
<div id="category3">
<strong>Question 3:</strong> The correct answer is poor and love your job because it's better to be poor and happy than rich and happy. Well that's what I think anyway.
</div>
<div id="category4">
<strong>Question 4:</strong> The correct answer is homeless with family and friends because it's better to be poor and happy than sad and in a medium financial state.
</div>
<div id="category5">
<strong>Question 5:</strong> The correct answer is no legs because if you have no arms you can't do the dirty.
</div>
<div id="category6">
<strong>Question 6:</strong> The correct answer is a penis on your belly-button because you could have it amputated.
</div>
<div id="category7">
<strong>Question 7:</strong> The correct answer is do it and nobody knows. Why would you want people to think that you molested a penguin?
</div>
<div id="category8">
<strong>Question 8:</strong> The correct answer is snowsuit in the desert. You wouldn't want to catch hypothermia as it's worst than hyperthermia, plus that penguin might get you back while you're out there.
</div>
<div id="category9">
<strong>Question 9:</strong> The correct answer is watch paint dry everyday for 1 hour for the next 10 years because if you lose count of the sand half way through counting you'd have to start all over again.
</div>
<div id="category10">
<strong>Question 10:</strong> The correct answer is silent but deadly because you could just blame it on somebody else, nobody will know where it came from.
|
|
|
|
|
var TrueArray=new Array // numbers only of correct inputs
(
2, // 1 so fist input is correct, 2 so second input is correct
...
// false second input is correct
);
var TrueArrayLength=TrueArray.length;
insert function onkeypress or onmousewover ... what you want
<input id="q1a" type="radio" name="q1" value="a" onmouseover="javascript:GetTrueFalse(1,1);"/><label for="q1a"> 2 foot tall</label>
function GetTrueFalse(NumberOfQuestion,NumberOfCorrectfInput)
// NumberOfQuestion from 1 to TrueArrayLength
// NumberOfCorrectfInput value of field of array at index pos NumberOfQuestion-1
{
NumberOfQuestion--;
if((NumberOfQuestion>=0) && (NumberOfQuestion<TrueArrayLength)) // 0 to TrueArrayLength-1
{
if((NumberOfCorrectfInput>0) && (NumberOfCorrectfInput<3)) // 1 or 2
{
if(NumberOfCorrectfInput==TrueArray[NumberOfQuestion]) // got number of correct input ?
{
// correct e.g. alert("bingo!");
}
else
{
// not correct e.g. alert("nope");
}
}
}
}
have fun.
|
|
|
|