![]() |
new JS project...
Ok guys, I made myself a pretty cool new JS project and I tried to do it without your help but it's not going anywhere.
You can see it here: http://www.gatebattle.com/dynamic_row_and_checkbox.html What I want the user to do is enter a number where it says: "Enter # of Rows to create:" Then it will dynamically create rows. I used the onBlur function for the input box... If they enter 3, it creates 3 rows, but if they then enter 2, it removes one row... I figured this would be fun to do...there's other things I want it to do too, but I want to try to figure those items out myself, but right now I need to get over this hurdle... JS: Code:
<script type="text/javascript">Code:
<table width="1024" border="0" align="center" cellpadding="2" cellspacing="1">It's probably easier though to just go to my site and view the page source maybe?? |
When accessing the link I get a syntax error and an undefined variable notice:
Code:
Detaljer om fejl på websiden
|
Quote:
Line 16 is this.. function addRows(document.testform.get_rows_input.value){ So don't laugh at the code, I know that's wrong, but everything is closed off? I'll remove the paramater so it is just the function...let me know if that works for you.... function addRows(){ |
getRow = document.testform.get_rows_input.value
should be getRow = document.testform.get_rows_input.value; Not sure if that's the problem though. |
I don't use Firefox, see my user agent (its IE), and your code is wrong, because what your code is saying is basiclly this in php:
PHP Code:
|
Ok, I think I am getting some where. I can at least make it dynamically create a new row when I click off the input box.
So the onBlur() is working at least. Getting close! http://www.gatebattle.com/dynamic_row_and_checkbox.html BTW: I tested this in both IE and FF and it works... |
You're getting somewhere, but still not working in IE for me:
Code:
Detaljer om fejl på websidenAlso you're code is wrong when I'm typing a number, then it will just insert one row, so if I remove whats in the field, deslect it and select it and repeat, +1 row will be added with no data, just empty cells. The maximum selected checkboxes and current selection does not work either, but that might be due to the error above about get_rows_input is null ;) |
Quote:
The only part I'm working on right now is getting it to dynamically generate rows...everything else doesn't work... I don't even have code for the rest... So now that I can get it to at least make rows, I have to find a way to get the user input value and add it to the FOR loop so it will generate N number of rows based on the input... fun stuff!! |
Ok, getting somewhere, now if you enter 7, it creates 7 rows...
3...3 rows... 5...5 rows.... etc.... The only issue is that it only ADDS rows... So if i already have 5 rows and I enter 2, it adds up to 7 instead of shrinking to 2 rows.... So now I will have to work on the deleting function..... |
Quote:
Quote:
|
Quote:
But you get credit... :-P Still waiting for this JS stuff to sink in...it's only been about 2-3 days I even started reading how to code in JS.... |
Alot more errors now, I think you will be better off using a framework to do the basics across browsers: document.write(countMe); -- that just prints the code thats in the function "countMe".
Your counter function seems wrong, as you name all of them 'checkbox', so something alon the lines of: javascript Code:
|
Quote:
I know, I apologize, I just feel if I try to use any framework right now, I won't really learn the basics of JS. Do you have your browser set to some kind of strict coding or something? I am viewing this in both IE and FF and it reveals no errors at all? Heck, I'm even trying it out on Safari too and no errors pop up? As for the output for "countMe", That I do I see...I was messing around with my code and it got late at night and I just left it there..... |
Why the heck is my code being printed to the screen? I am using the latest code that Kalle provided. And I am printing it out like this:
Code:
<script type="text/javascript"> |
Quote:
What a framework however gives you is an abstract interface to talk to the browser via DOM. So by using a framework you will still get to learn the JS syntax, but the DOM part will be mostly abstract and you won't learn how each browsers interact and works, which isn't important for now until you get the base gasp of it. |
Quote:
javascript Code:
Assuming that checkboxes_count() ofcourse returns a numeric value for use here. Instead of using document.write, you can always do a: HTML Code:
<p>Times clicked: <span id="count">0</span></p> |
Quote:
Code:
"for(y in x)"I will go ahead and read up on Mootools....I'll go with your suggestion and hope in the process the fundamentals of JS don't escape me... |
Quote:
Here's what I'll do... I want to finish this project up in straight up JS code. Then when it's done, I will jump on Mootools!!! I'll try my best to finish it up today! |
Quote:
javascript Code:
Arrays or objects to iterate are set on the right side, unlike foreach in PHP where its on the left side. The following example would looks like this in php: PHP Code:
|
Quote:
You are a lifesaver! |
| All times are GMT. The time now is 09:53 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0