Loading...
Copy code
Close
Permalink
Close
Please tell us why you want to mark the subject as inappropriate.
(Maximum 200 characters)
Report Inappropriate
Cancel
Private Message
From :
guest
To :
Subject :
Content :
Type the characters you see in the picture below.
Send
Cancel
From :
guest
To :
Subject :
Content :
Type the characters you see in the picture below.
Send
Update
Cancel
Feedback
Email ID
Subject :
Comments :
Send
Cancel
Private Message
Type the characters you see in the picture below.
Type the characters you see in the picture below.
Attach files
Desktop
Google Docs
Each Attachment size should not exceed 1.0 MB.
Max no of attachments : 3
Loading User Profile...
guest
Response title
This is preview!
Attachments
Publish
Back to edit
Cancel
(
)
Sign In
New to this Portal? Click here to
Sign up
You can also use the below options to login
Login with Facebook
Login with Google
Login with Yahoo
jQuery
Plugins
UI
Meetups
Forum
Blog
About
Donate
All Forums
Recent Posts
Log In
Search
jQuery
Search
jQuery Forum
Screen name:
mexx91
mexx91's Profile
1
Posts
1
Responses
0
Followers
Activity Trend
Last 30 days
Last 30 days
Date Interval
From Date :
To Date :
Go
Loading Chart...
Posts
Responses
PM
Show:
All
Discussions
Questions
Ideas
Problems
Expanded view
List view
Private Message
The page reloads after my function is completed, so my result is just shown for 1/2 second.
[2Replies]
12-Jan-2012 10:49 AM
Forum:
Using jQuery
Hey,
i got a problem with my jQuery function.
The function takes the value of an form input (binary number) and converts it into a decimal number.
After calculating the result, the result should be show in a div container, but when I execute the function
the result is shown for a small moment but then the side is reloading and the div container with the result is empty again.
jQuery:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
$(document).ready(function() {
var ergebnis ="";
$('#submit').click(function() {
convert();
});
});
function convert() {
var binaryString = $("#input").val();
$("#input").val(binaryString);
var ergebnis = 0;
var stringArray = [];
var intArray = [];
var i = 0;
console.log("Read String: " + binaryString);
stringArray = binaryString.split('');
console.log("Splited: " + stringArray);
var reversedStringArray = stringArray.reverse();
console.log("Reversed: " + reversedStringArray);
for(i=0; i < stringArray.length; i++) {
intArray[i] = parseInt(stringArray[i]); // Wandelt StringArray in IntArray um
ergebnis = ergebnis + (intArray[i]) * (Math.pow(2, (i)));
console.log(i + ": " + ergebnis);
}
console.log("Joined: " + intArray.join('') );
$("#ergebnis").html("Ergebnis: " + ergebnis);
console.log("Ergebnis:" + ergebnis);
//alert("Ergebnis: " + ergebnis);
};
HTML:
Binärzahl:
How cani fix it?
I think it´s a small thing but I'm using jQuery just for a few days now.
Thanks for your help.
Mexx
«Prev
Next »
Moderate user : mexx91
Forum