[ 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


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]

I tried, no luck

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

>> No.34522756


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

>> No.34522773


If you are using jquery.

>> No.34522788

Try a search engine

>> No.34522794

yeah I forgot the document.write on my code.

>> No.34522801


>> No.34522825

indeed I am

I actually found the function call


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

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]

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

>> No.34523081

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]

Didn't work but did you mean like this?

p.s. thx for your patience with me

>> No.34523211

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

>> No.34523336

Are you telling me to:

function write_added_text(){

>> No.34523362

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]


>> No.34523548

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]

Like this?

The code still shows as above

>> No.34523811


this will do

>> No.34523842

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


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

thx for this link,

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

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

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


>> No.34524072

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

>> No.34524085

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

>> No.34524234

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

>> No.34524284

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

Just follow the new bostob videos (typo on purpose)

also add a ; after your return line

>> No.34524370

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

What do you suggest?

>> No.34525094

Stop using document.write

>> No.34525132

it's what the book tells me to me write

>> No.34525186

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

>> No.34525385

JavaScript a Beginner's Guide Third Edition

>> No.34526364

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]

>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]

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

>> No.34527941


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


>> No.34527998


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

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

I think OP is long gone

>> No.34528386

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

>> No.34528511


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

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

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

Son of a gun, that did it

Thank you so much

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

>> No.34528753

muh package manager

>> No.34528816

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



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]


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

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

>> No.34528932

do you have any recommendations for js?

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


>> No.34529045

>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.

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

>> No.34529122

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

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

Have fun anon

>> No.34529208

Eloquent Javascript, its free on the internet

>> No.34529222


w3c schools is pretty useful too.

>> No.34529250

Go kill yourself in a fire

>> No.34529316

Why are we not using jquary faggots?

>> No.34529323

>not having arguments
this site is shit

>> No.34529337


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

>> No.34529356

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

>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]

but muh w3schools html certification for $100

>> No.34529591

Eeew, jQuery.

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


>> No.34529732

Thx brah, much appreciated

>> No.34529781

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

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

>> No.34529998

thats common practice really..

>> No.34530004

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]

I like to exercise my right to remain anonymous

>> No.34530443

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

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]

>railroad diagrams
am i supposed to understand that shit?

>> No.34531024

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)
Password [?]Password used for file deletion.