|
really useful! thanks a lot!
|
|
|
|
|
/*
Dear all,
<script>
function Array2D(x,y){
this.length = x*y;
this.x = x;
this.y = y;
for(var i=0 ; i<this.length ; i++){
this[i] = null;
}
this.get = function(x,y){
return this[x*this.x+y];
}
this.set = function(x,y,value){
this[x*this.x+y] = value;
}
}
</script>
<script>
var a2d = Array2D(10,10);
a2d.set(2,3,"2");
alert(this.get(1,2));
</script>
Uncaught TypeError: Cannot read property 'set' of undefined
How does it happen?and what should i do to avoid this?
*/
|
|
|
|
|
It's undefined because you ahven't returned anything form your Array2D function. Try adding
return this;
at the end of it.
Also, your
alert(this.get(1,2));
shouold be
alert(a2d.get(1,2));
|
|
|
|
|
thanks a lot! it works! 
|
|
|
|
|
I need to check whether control id is available or visible (whether it is defined or undefined). how to check this process in javascript. any example pls
|
|
|
|
|
This code will check if an element exits with that ID:
if(document.getElementById(id)!=null)
{
}
You can use JQuery to check if the element is visible:
$('#MyID').is(':visible')
|
|
|
|
|
function validate()
{
var dd = document.frmreq;
if (mailid.value == "")
{ alert ("Pls enter mailid"); return false;
}
if (dd.description.value == "")
{
return false;
}
return true;
}
mailid and mobileno is get from DB
here, i can't able to get the mailid and mobileno for validation. any one explain me the problem here.
|
|
|
|
|
Use the getElementById method[^] to access the elements:
function validate()
{
var mailid = document.getElementById("mailid");
if (mailid.value === "")
{
alert("Please enter mailid");
mailid.focus();
return false;
}
var description = document.getElementById("description");
if (description.value === "")
{
alert("Please enter description");
description.focus();
return false;
}
return true;
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Just taking my first javascript coding class and having a hard time with understanding all of it. Wanted to know what the main difference is in for and while loops and when it's best to use either one? Also want to know what the difference is between document.write and getElementById? Does it matter which one to use for output?
|
|
|
|
|
Member 11972043 wrote: Wanted to know what the main difference is in for and while loops and when it's best to use either one? This is not something unique to JavaScript so I suggest you google for vs while loops and you'll see the difference. There's a subtle difference and most often depends on your preference to which one you use. W3Schools.com is a good resource. For example, see http://www.w3schools.com/js/js_loop_while.asp[^]
Member 11972043 wrote: Also want to know what the difference is between document.write and getElementById? These cannot be compared to each other. document.write does what it sounds like. It calls the write method on the document. The document is the webpage so this can be used to write something on the page. I suggest not using it because you won't control, very well, where the output is. It's much better to put output into a control so that you can style it, position it, etc.
That's where getElementById comes in. It also does as it's name implies. It gets an element on your webpage by passing in the id of that element.
So, for example, if you wanted to do some output you could do something like this:
document.getElementById("myText").value = "Some Text";
Again, W3Schools.com, http://www.w3schools.com/jsref/met_doc_getelementbyid.asp[^]
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
The main difference between for and while is that (if you know how these conditional statements will work).
for is used to do a definite number of task i.e you know the limit for the process, say you want to print the number of anything in an array,etc.you can use counter to proceed further.
less interaction between user and machine.
while is same as for in some cases,you when the process will end but still in places like getting an input from the user which decides when the end should occur you have go with while.you can use you counters as well as boolean values.
i.e you can ask the user to whether continue or break after every successful process.interaction between the user and machine .
getelementbyid is used to get an input to a variable by using an id attribute from tag.
write is used to output the values assigned to it.
instead of this you can you use console.log().
sorry if it wasn't helpful because i'm new.
|
|
|
|
|
How can I add an image with a submit button but still show the words submit?
|
|
|
|
|
|
Hello. I have been asked to build a cross-browser extension, and I have never built one before. I wondered, firstly, what sort of timeframe I should be looking at, and secondly, what sort of fee? I am also new to contract work, having left the industry as a data harvester and junior developer for self-employment, just a few months ago. Should I be charging per hour, or a flat fee for such a project?
|
|
|
|
|
We can't really answer that question for you. We have no idea what the extension is supposed to do, what skills you have, how quickly you can pick up new skills if needed, or how quickly you can work. We also have no idea whether your client would accept an open-ended hourly rate, or expects you to quote and charge a fixed fee.
If you charge a fixed fee and it doesn't completely cover your time, will you gain anything? Will you learn additional skills that you can use in future projects? Will you generate good-will with the customer, and potentially get extra work or referrals from them in the future?
Coming up with accurate estimates is hard enough for our own work; it's virtually impossible for someone else's!
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
sir i want the image to be dispalyed in a browser when we choose the image from the option choose file and click on submit .I wrote the code as below
Quote: <html>
<body>
Please enter your details for our Dating Website!
<form action="https://amazonstore.com" method="POST">
Your Face
<label for="image">Your Image</label>
<input type="file" name="FileToUpload" value="ChooseFile" required>
<label for="preview">Image Preview: </label></label>
Quote: </form>
<input type="submit" name="submit" value="submit" align=="center">
</form>
</body>
</html>
modified 8-Oct-15 10:26am.
|
|
|
|
|
42 - it's the answer to everything.
Now try actually asking a question.
Remember, we can't see your screen, access your computer, or read your mind, so you need to explain what the problem is as if we don't know what you're talking about (because we don't).
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hi,
i am fairly new to programming.
i am making a website where the front page is simply an image, think google with just a picture in the center.
however there is no search bar no nothing, only the witty and curious enough to click the image will get login/register buttons where they can further click them to enter user pass email information
so far i have something like this
which i want to redirect to a function
var spawnButtons=function(){
that ultimately makes the login/register buttons/links whatever you call them appear which then go on to make the username/password/email appear/disappear depending on which login or register is clicked which could then be safely entered(i'm assuming some sort of php)}
i hope for this to all be on the same page for aesthetic purposes but if not i can understand. so everything is hidden essentially until it is clicked.
thanks.
|
|
|
|
|
Peter Roman wrote: <img src="D:/Pictures/JIT.png" width="347" height ="176" />
You can't use local paths to display an image on a website. You need to use a URL, either absolute (src="http://yoursite/pictures/jit.png" ), relative to the current site (src="/pictures/jit.png" ), or relative to the current page (src="pictures/jit.png" ).
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thanks for the response bro i really appreciate it,
i think i'm mainly worried about making the image not a button (so that a hand clicker icon for the mouse doesn't appear) and then making the register and login button come out of hiding as well as displaying the login and/or register forms whenever clicked, hiding the other if switched all on the same page. it might not be possible or impractical or whatever but the image source right now is sort of arbitrary in terms of example although i appreciate what you're saying.
so yeah, if you know how to do that pls let me know where i can find the resource for that![Java | [Coffee]](https://codeproject.global.ssl.fastly.net/script/Forums/Images/coffee.gif)
|
|
|
|
|
What you're describing is a single-page application[^]. There are various frameworks around to help create SPAs - for example:
An SPA is quite an ambitious project to start with. It would probably be easier to start with a more traditional multi-page application, at least until you get familiar with HTML, CSS and Javascript.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
okay cool, thanks.
i mean i'm not totally new new like i didn't start yesterday. i've coded some in college but that was a c++ course, and then of course there's resources like khan academy which only teach so much you know?
i think embarking on an ambitious project is okay if there's help around, which clearly there is since people that know what they're doing like you are here to respond haha. i'm not in a rush but i do want this website to look simple, neat, and clean, so some of the traditional website styles aren't exactly my taste.
plus when all is said and done, i think that this is probably going to be a life-long project that i'm going to focus on, so like it's my first and my last? unless i branch out in the future, but yeah. i want to get it right the first time, even if it takes a little less than forever =]
|
|
|
|
|
It's actually straightforward enough - no need to go the whole SPA route.... IMO too much of web programming these days is all about using sledgehammers to crack nuts.
Simply wrap your image-button and your registration form in div tags, adn set that of the reg form to be hidden to start with.
<div style="display:none;" id="reg-form">
then, on the user clicking the image call a JavaScript function that reverses the hidden attributes of both divs.
That's the general principle, anyway.
|
|
|
|
|
thanks, but i have no idea for what the code is after all that stuff you said, haha. what is the code for hidden to start with? and also how do i reverse the hidden attibutes?
|
|
|
|
|
With all due respect then, I think perhaps you need to start with some basics before worrying about building a site.... http://www.w3schools.com/[^] is a good reference place for starting out.
However - below is a very basic page showing the essence of what you're after - but don't expect me or anyone else here to do your work for you. Learn what you can, try things, and ask questions on specific things you get stuck on.
<html>
<head>
<title></title>
<style type="text/css">
.show {
display:inline;
top:0;
left:0;
width:100%;
height:100%;
}
.noshow {
display:none;
}
.handy {
cursor:pointer;
}
</style>
<script type="text/javascript">
function enterSite() {
document.getElementById("splash").className = "noshow";
document.getElementById("login").className = "show";
}
</script>
</head>
<body>
<div id="splash">
<img src="relative path to image" onclick="enterSite()" alt="Click to enter site" class="handy" />
</div>
<div id="login" class="noshow">
<h2>Log in here</h2>
</div>
</body>
</html>
|
|
|
|