Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Warning: Noob at javascript, Need help!
Old 03-29-2007, 08:34 PM Warning: Noob at javascript, Need help!
The PHP Professor

Posts: 340
Name: Alex
Location: Behind You
Trades: 0
Hello everybody, As you have seen on my post title i am not very good at javascript, But i know a little. I need to know the following, and i know that it is possible:

On a form submission i need an image to appear in a <div>. so, i have to following code, but i donot have all that backend stuff:

Code:
<input type="submit" name="submit" value="Submit" onsubmit="javascript:loadform">
 
<div id="image" style="display:none">Loading...</div>
i dont know if this is at all right but i told you i was a noob. :-)
microcolt is offline
Reply With Quote
View Public Profile Visit microcolt's homepage!
 
 
Register now for full access!
Old 03-30-2007, 12:24 AM Re: Warning: Noob at javascript, Need help!
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,938
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
Trades: 0
Where and how do you need this information to appear? You can always add the image in post-submission when you process the form.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
(my blog)


Please login or register to view this content. Registration is FREE
(with proof)
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Old 03-30-2007, 04:23 PM Re: Warning: Noob at javascript, Need help!
Extreme Talker

Posts: 169
Trades: 0
So you want an image to appear where it says "Loading..." in your code, or do you want an image to appear behind that?
Either you could in your script alter the style of the div by doing something like
objectName = document.getElementById('image');
objectName.style.background = 'urlimagelocation.jpg) --- etc you know the drill';
or use innerHTML, but really you shouldn't, it is teh_devil to some, so just read this:
http://slayeroffice.com/articles/inn..._alternatives/

But I'm still not really sure exactly what you want to do... so if you could clear me up, that would be great.
__________________
George Bush would never take me alive.
MJM_RDS is offline
Reply With Quote
View Public Profile
 
Old 03-30-2007, 04:37 PM Re: Warning: Noob at javascript, Need help!
The PHP Professor

Posts: 340
Name: Alex
Location: Behind You
Trades: 0
ok i will explain,

When i press the "Submit" button a image primarialy a .GIF will be displayed in the "<div id="image"></div>", so if i put the div on the top of the page the image will be displayed there and vis versa.

But i do not know how to make all the functions and stuff.
__________________
Go Kirby! <(" . "<) (^" . "^) (>" . ")> Talkupation!
microcolt is offline
Reply With Quote
View Public Profile Visit microcolt's homepage!
 
Old 03-30-2007, 06:45 PM Re: Warning: Noob at javascript, Need help!
Extreme Talker

Posts: 169
Trades: 0
well one thing you could do is this:
instead of "javascript:loadform" call another function called whatever
so change to "javascript:whatever()"
Code:
function whatever()
{
  imageactivate();
  loadform();
}

function imageactive()
{
  var imgdiv = document.getElementById('image');
  imgdiv.innerHTML = '<img src="*****" width="" height="" alt="" />';
}
This would be the easiest, though you could expand it since I'm thinking you'll need to make the image disappear again (just add a boolean parameter to check)
The only way I can think of doing this without innerHTML is to write your own createImageNode function which since you're a newbie is too much effort.
__________________
George Bush would never take me alive.

Last edited by MJM_RDS; 03-30-2007 at 06:45 PM.. Reason: missing code close bracket
MJM_RDS is offline
Reply With Quote
View Public Profile
 
Old 03-31-2007, 01:29 AM Re: Warning: Noob at javascript, Need help!
The PHP Professor

Posts: 340
Name: Alex
Location: Behind You
Trades: 0
hey, thanks but i tested your script and i am getting errors. i am using the following code.

Code:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
<script type='text/javascript'>
function whatever()
{
imageactivate();
loadform();
}
function imageactive()
{
var imgdiv = document.getElementById('image');
imgdiv.innerHTML = '<img src="loading.gif" width="23" height="8" alt="Loading..." />';
}
</script>
</head>
<body>
<input type='submit' name='submit' value='Submit' onclick='javascript:whatever()'>
</body>
</html>
__________________
Go Kirby! <(" . "<) (^" . "^) (>" . ")> Talkupation!
microcolt is offline
Reply With Quote
View Public Profile Visit microcolt's homepage!
 
Old 03-31-2007, 11:42 AM Re: Warning: Noob at javascript, Need help!
Extreme Talker

Posts: 169
Trades: 0
I have a question, do you actually have a loadform function? I assumed you had since that is what you are calling originally, but now it isn't in your JS.
Also you changed your code so that now you don't have the element with the ID "image" anymore.
Change your html so this is included again
Code:
<div id="image" style="display:none">Loading...</div>
What I wrote is very simple JS, I think the best thing you can do is simply Google what these methods actually do.
__________________
George Bush would never take me alive.
MJM_RDS is offline
Reply With Quote
View Public Profile
 
Old 03-31-2007, 04:27 PM Re: Warning: Noob at javascript, Need help!
The PHP Professor

Posts: 340
Name: Alex
Location: Behind You
Trades: 0
no, i do not have a load form function, i was just using it for an example. Heres what the form looks like now, and it still doesnt work:



Code:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
<script type='text/javascript'>
function whatever()
{
  imageactivate();
  loadform();
}
function imageactive()
{
  var imgdiv = document.getElementById('image');
  imgdiv.innerHTML = '<img src="loading.gif" width="" height="" alt="Loading..." />';
}
</script>
</head>
<body>
<div id="image" style="display:none">Loading...</div>
<input type='submit' name='submit' value='upload' onclick='javascript:imageactivate()'>
</body>
</html>
__________________
Go Kirby! <(" . "<) (^" . "^) (>" . ")> Talkupation!
microcolt is offline
Reply With Quote
View Public Profile Visit microcolt's homepage!
 
Old 04-01-2007, 12:13 PM Re: Warning: Noob at javascript, Need help!
Extreme Talker

Posts: 169
Trades: 0
Ok, I didn't realise loadform() was supposed to be an example, so you can remove the whatever function. And call imageactive directly, which you are not. There's a typo, probably copied from the code I wrote. Do you know CSS? Just asking because you have this in your code
style="display:none"
Google it if you don't understand what that means. Either way here's another solution for you. You could have your div like this:
Code:
<div id="image" style="display:none"><img src="loading.gif" width="" height="" alt="Loading..." /></div>
and then use JS to change the style attribute by doing this instead of the innerHTML:
Code:
imgdiv.style.display="inline";
__________________
George Bush would never take me alive.
MJM_RDS is offline
Reply With Quote
View Public Profile
 
Old 04-02-2007, 04:27 PM Re: Warning: Noob at javascript, Need help!
The PHP Professor

Posts: 340
Name: Alex
Location: Behind You
Trades: 0
i used the code below EXACTLY as i used it and it still doesnt work:

Code:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
<script language='Javascript'>
function imageactive()
{
  var imgdiv = document.getElementById('image');
  imgdiv.style.display="inline";
}
</script>
</head>
<body>
<div id="image" style="display:none"><img src="loading.gif" alt="Loading..." /></div>
<input type='submit' name='submit' value='upload' onclick='javascript:imageactivate()'>
</body>
</html>

What is wrong, i dont get any errors in my browser?
__________________
Go Kirby! <(" . "<) (^" . "^) (>" . ")> Talkupation!
microcolt is offline
Reply With Quote
View Public Profile Visit microcolt's homepage!
 
Old 04-03-2007, 05:01 AM Re: Warning: Noob at javascript, Need help!
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,519
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
most of the trick is in the typing, so shall we play "spot the difference" ??

function imageactive()

onclick='javascript:imageactivate()'>
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 04-03-2007, 07:52 PM Re: Warning: Noob at javascript, Need help!
The PHP Professor

Posts: 340
Name: Alex
Location: Behind You
Trades: 0
AWWW WOW i cnt belive i spellid that awrong, i a freaking idiot :-(
__________________
Go Kirby! <(" . "<) (^" . "^) (>" . ")> Talkupation!
microcolt is offline
Reply With Quote
View Public Profile Visit microcolt's homepage!
 
Old 04-03-2007, 08:16 PM Re: Warning: Noob at javascript, Need help!
The PHP Professor

Posts: 340
Name: Alex
Location: Behind You
Trades: 0
See i told you i was a noob, oh and one more thing, whats the script to refresh? like onclick='javascript:location.self'> or whatever
__________________
Go Kirby! <(" . "<) (^" . "^) (>" . ")> Talkupation!
microcolt is offline
Reply With Quote
View Public Profile Visit microcolt's homepage!
 
Old 04-04-2007, 06:25 AM Re: Warning: Noob at javascript, Need help!
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,519
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
it should be
javascript:self.location = self.location

The "correct" way is

javascript:window.location.reload()

or you can use

javascript:window.history.go(0)
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to Warning: Noob at javascript, Need help!
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.69261 seconds with 12 queries