Quantcast
[ 3 / biz / cgl / ck / diy / fa / g / ic / jp / lit / sci / tg / vr / vt ] [ index / top / reports / report a bug ] [ 4plebs / archived.moe / rbt ]

Due to resource constraints, /g/ and /tg/ will no longer be archived or available. Other archivers continue to archive these boards.Become a Patron!

/g/ - Technology


View post   

[ Toggle deleted replies ]
File: 15 KB, 437x308, function.png [View same] [iqdb] [saucenao] [google] [report]
34522570 No.34522570 [Reply] [Original] [archived.moe] [rbt]

Did I code this function correctly?

The text won't show on my html

>> No.34522618

>>34522570
>>.js

try writing that un your template/html

>> No.34522642

the functions looks fine although I don't see you calling for the function

>> No.34522731
File: 28 KB, 886x487, function_html.png [View same] [iqdb] [saucenao] [google] [report]
34522731

>>34522618
I tried, no luck

>>34522642
my book told me about calling my functions but didn't give me examples on how

>> No.34522756

>>34522731
document.write(get_added_text());

that will work, you seem to be a real beginner in programming

>> No.34522773

>>34522731
<script>
$(document).ready(function(get_added_text()){})
</script>


If you are using jquery.

>> No.34522788

>>34522731
function()?
Try a search engine
http://homepage.ntlworld.com/kayseycarvey/jss3p5.html

>> No.34522794

>>34522756
>>34522773
yeah I forgot the document.write on my code.

>> No.34522801

>>34522570
try:
$(document).ready();

>> No.34522825

>>34522756
indeed I am

I actually found the function call

functionname();

should I replace functionname with get_added_text();?

I've experimented with the placement but I'm not sure if the call comes after the end of the curly brace or not

>> No.34522904

>>34522825
your functions returns a value, nothing else is done with it when called on it's own.

you could change return added_text; with document.write(added_text); if you want your function to write instantly

>> No.34522986
File: 16 KB, 370x389, function_js.png [View same] [iqdb] [saucenao] [google] [report]
34522986

>>34522904
I don't think I've called the function yet because I'm still not seeing those results

>> No.34523081

>>34522986
just use get_added_text(); anywhere, I recommend to put it underneath your last document.write();

Also renaming your function to write_added_text would make more sense now

>> No.34523162
File: 5 KB, 309x111, function_html2.png [View same] [iqdb] [saucenao] [google] [report]
34523162

>>34523081
Didn't work but did you mean like this?

p.s. thx for your patience with me

>> No.34523211

>>34523162
ow no sorry, I meant above your function where you have all those other document.write calls

>> No.34523336

>>34523211
Are you telling me to:

get_added_text();
function write_added_text(){

>> No.34523362

>>34523336
Call write_added_text(); not get_... as you removed that function already.

I need more coffee this evening

>> No.34523396
File: 10 KB, 747x111, success_pending..png [View same] [iqdb] [saucenao] [google] [report]
34523396

>>34523362
Success?

>> No.34523548

>>34523396
inside the write_added_text function change document,write... to document.write(added_text), that will do somewhat

>> No.34523646
File: 6 KB, 313x120, function_js2.png [View same] [iqdb] [saucenao] [google] [report]
34523646

>>34523548
Like this?

The code still shows as above

>> No.34523811

>>34523646
http://pastebin.com/zswEH0rA

this will do

>> No.34523842

>>34523646
/g/ hates the new boston but perhaps it might help you.

http://thenewboston.org/list.php?cat=10

>> No.34524018
File: 7 KB, 416x147, still.png [View same] [iqdb] [saucenao] [google] [report]
34524018

>>34523842
thx for this link,

>>34523811
I typed all that in (save for the comments)
and I still get this page. Is the code posted suppose to be hidden in the page or should any of the words be showing?

>> No.34524035

>>34522570
>sublime text
You can do better than that, man.

>> No.34524041
File: 20 KB, 417x444, functions_js3.png [View same] [iqdb] [saucenao] [google] [report]
34524041

>>34524018

>> No.34524072

>>34524035
I love it, it works exactly how I want it to and it looks nice

>> No.34524085

>>34524035
Do you really think web "programmers" are mentally capable of anything beyond a shiny Notepad?

>> No.34524234

>>34524085
Proffessional web programmers do. Not the one year experience wordpress users.

>> No.34524284

>>34524234
I started JS about a week ago, it does a good job of immersing me in the programming experience by not overwhelming me like C++ did. I intend to learn C++ but it will come later

>> No.34524293

>>34524041
Just follow the new bostob videos (typo on purpose)

also add a ; after your return line

>> No.34524370

>>34524293
thx didn't catch that, still doesn't work but I felt like I had plenty of chances to figure it out by now, I'm going to use those videos and find out what's missing

>> No.34524522

http://pastebin.com/wZPuk1BJ made this in the time I had to wait for my drivers to crash as I was figuring out why it happend.

anyhow, perhaps that works

>> No.34524596

>>34524085
What do you suggest?

>> No.34525094

Stop using document.write

>> No.34525132

>>34525094
it's what the book tells me to me write

>> No.34525186

>>34525132
What book? Document.write was long ago realized to be a real mistake of the DOM.

>> No.34525385

>>34525186
JavaScript a Beginner's Guide Third Edition

>> No.34526364

>>34524085
I don't get where everyone's learning about ST2, /g/'s pretty against it whenever it appears but it keeps appearing from somewhere. I'd never heard of it till recently

>> No.34526569

Jesus Christ, so many people here claim to know a lot about programming yet none you guys know what's wrong with OP's code. Just putting document.write( get_added_text() ); after the function definition would work!

>> No.34526632
File: 49 KB, 512x288, 128789_512x288_generated.jpg [View same] [iqdb] [saucenao] [google] [report]
34526632

>>34522570
>var textpart1
>var textpart2
>var added
>not just returning "this is fun!"

>> No.34527215
File: 38 KB, 964x528, why.png [View same] [iqdb] [saucenao] [google] [report]
34527215

>>34526632
why does the code show up in html and just the return value?

>> No.34527941

>>34522570

Why can't you directly change the value of an html tag?

document.getElementById("")

>> No.34527998

>>34527215
change
document.write(write_added_text);
to
document.write(write_added_text());

>> No.34528304
File: 44 KB, 916x406, JavaScript.png [View same] [iqdb] [saucenao] [google] [report]
34528304

Would this be suitable, or am I missing the point of the question?

>> No.34528363

>var 1
>var 2

Just use an array nigga, now you can add as much text as you want.

>> No.34528374

>>34528304
>http://pastebin.com/zswEH0rA
I think OP is long gone

>> No.34528386

>>34528374
didn't mean to greentext that.. still had it selected but didn't see it when posting.

>> No.34528511

>>34528386

No worries... I'm not overly familiar with JavaScript, so I've never used document.write().

It seems a little odd to use JavaScript to write out HTML; it doesn't even show up if I do view source in Firefox.

>> No.34528694

>>34528511
document.write() is 'injects' HTML, so can be used to dynamically change the page when you click stuff. It's used a lot in the wild, but I think it's not best practice and should only be used if there's not alternative.

Not sure what you mean with your Firefox but it's supported cross browser.

>> No.34528723

>>34524596
Ignore them, sublime text is just fine
inb4 vim, they can't formulate an actual reason for why it is better, it isn't, just free.

>> No.34528730

>>34527998
Son of a gun, that did it

Thank you so much

>>34528374
not quite, I'm just multitasking in the living room and almost forgot to check the thread

>> No.34528753

>>34524035
muh package manager

>> No.34528816

>>34528730
Glad to be of help, I hope you get a feeling what the difference is; the brackets make it execute the function while without brackets it's the function itself, which can also be passed around as a parameter. Important difference in Javascript.

>> No.34528828

>>34522570

document.write

no, you did not.
get a proper book on javascript and use jquery for dom.
or learn c, c++, c# instead.

>> No.34528852
File: 36 KB, 640x480, JavaScript.png [View same] [iqdb] [saucenao] [google] [report]
34528852

>>34528694

To clarify, this is what I see for view source initially. If I press the button, it runs the script, but then the source code no longer shows.

>> No.34528872

is that sublime text

>> No.34528921

>>34528816
Noted, I'm going to have to get dirty with it some more to understand it better

>> No.34528932

>>34528828
do you have any recommendations for js?

>> No.34529009
File: 53 KB, 600x450, JavaScript-the-good-parts.jpg [View same] [iqdb] [saucenao] [google] [report]
34529009

>>34528932

>> No.34529045

>>34528723
>Ignore them, sublime text is just fine
>inb4 vim, they can't formulate an actual reason for why it is better, it isn't, just free.

Actually, it's usually the opposite.
https://sublimebullshit.wordpress.com/2013/03/22/response-to-andrew-rays-blog-post/

Any rumors of Sublime Text being even anywhere near Vims awesomeness are greatly exaggerated.

>> No.34529122

>>34528852
I guess because Firefox's view source does not show the live-source like Firebug does. Chrome works better I think, I love the developer tools in Chrome. It shows everything live

>> No.34529167

>>34528921
Nice, try stuff, google your ass off and don't give up. Also this is a good book >>34529009

Have fun anon

>> No.34529208

>>34528932
Eloquent Javascript, its free on the internet

>> No.34529222

>>34528921
>>34529167

w3c schools is pretty useful too.

>> No.34529250

>>34529222
Go kill yourself in a fire
http://www.w3fools.com/

>> No.34529316

Why are we not using jquary faggots?

>> No.34529323

>>34529250
>not having arguments
this site is shit

>> No.34529337

>>34529250

In that case, I retract my statement. Thanks for the read!

>> No.34529356

>>34529250
A lot of stuff on the internet isn't 100% accurate.. you'll have to learn that yourself. I've spotted some minor errors in w3schools but it isn't that bad.

>> No.34529407

>>34529356
>W3Schools.com is not affiliated with the W3C in any way. Members of the W3C have asked W3Schools to explicitly disavow any connection in the past, and they have refused to do so.
There's a difference between hosting false information and hosting false information while pretending you're part of something like the W3C.

>> No.34529447
File: 367 KB, 786x1099, html.png [View same] [iqdb] [saucenao] [google] [report]
34529447

>>34529250
but muh w3schools html certification for $100

>> No.34529591

>>34522801
Eeew, jQuery.

>> No.34529603
File: 278 KB, 806x720, u wot m8.png [View same] [iqdb] [saucenao] [google] [report]
34529603

>>34529447

>> No.34529732

>>34529167
Thx brah, much appreciated

>> No.34529781

>>34529407
I've never thought they were part of the W3C. In my eyes, w3schools also never claims or even hints that.

They are way off with W3C anyway, they just give users some HTML examples to play with.

>> No.34529846

also OP you don't have to edit out your user name

who cares what it is? it's not like you'll get hacked if people see C:\john or something

>> No.34529896

>>34529846
Maybe he doesn't want people from his school or college to know he is a filthy 4channer

>> No.34529998

>>34529846
thats common practice really..

>> No.34530004

>>34529896
yeah there's probably only 1 tom richards in the world

>> No.34530261
File: 12 KB, 243x251, honto_ni_no_cash.jpg [View same] [iqdb] [saucenao] [google] [report]
34530261

>>34529846
I like to exercise my right to remain anonymous

>> No.34530443

>>34528828
Learning jquery before mastering javascript is like learning how to run before learning how to walk. For stuff like what OP is doing, there's no need to use jquery.

>> No.34530719

>>34530443
True this. I had a class where they taught Javascript through first Prototype and the final assignment was in JQuery. Ofcourse only the guys who already knew Javascript passed.

JQuery is useless if you have no clue what's it doing to make your life easier.

>> No.34530895
File: 457 KB, 390x293, 45983498778943.gif [View same] [iqdb] [saucenao] [google] [report]
34530895

>>34529009
>railroad diagrams
am i supposed to understand that shit?

>> No.34531024

>>34530895
you specific problem is?
and keep in mind that you will see many more of those graphs in actual programming like sql

>>
Name (leave empty)
Comment (leave empty)
Name
E-mail
Subject
Comment
Password [?]Password used for file deletion.
Captcha
Action