Best Practice If Then Else
May 21, 2006
I'm wondering what the best practice is for a particular task I'm trying to
View 9 Replies
Jul 20, 2005
accomplish. I'm using two sets of radio buttons for a user to select values
from. These values then go into a couple of tables to show some heat loss
calculations depending on the values chosen I want the tables to have the
relevant values filled in. Is the best way to accomplish this a long list of
if then else type statements or is there a better way of doing this?
I am looking for advice on what is "best practice" regarding looping
View 4 Replies
Oct 16, 2007
through a form to check its checkboxes and associated data fields.
Here is what I am trying to do (Here is the page I am working on:
I provide a form for a user to enter up to twenty (M = 20) data pairs.
The user need not enter data for all twenty pairs, but
the user must indicate that data is present by checking the checkbox
beside each valid pair.
If a checkbox is checked, two things happen:
i) a counter, numRows, is incremented to keep track of the total
number of valid pairs entered.
ii) the associated two data values (being x and y) are checked to
ensure that they are valid numbers and, if so, are entered in an array
for use later.
Previously, my forms were small, and I was able to examine each
checkbox of a form individually:
"if (checkbox1.checked) do action A;
if (checkbox2.checked) do action B;
if (checkbox3.checked) do action C;
However, now that my form has twenty checkboxes, and may get bigger, I
would like to learn how to accomplish this task with a concise loop.
Following is my first attempt and it seems to work. If anyone can
suggest improvements for this code ....
I have been going back and getting rid of so many of my onclick's and such, trying to switch to a more unobtrusive method of adding events to anchors.
View 2 Replies
Apr 14, 2010
I've run into one snag that's kind of dissonant for me, and wondered if anyone had any advice.
By adding an event, you can turn:
<a href="#" onclick="something(); return false;>Click me</a>
<a href="new.html" class="something">Click Me</a>
But what goes in href if you don't have anything to actually link to? One example is a page I've written that is entirely self-contained, and all href's that drive the interface end up pointing to #. Is this acceptible in edge cases like these with the unobtrusive approach?
If someone has JS turned off the markup is essentially meaningless, so I was wondering how people deal with this lapse in the separation between behavior and structure.
I have a photo blog [url] and want to create an effect that fades-in the displayed picture when the page is loaded.
View 2 Replies
Jul 13, 2010
Currently I am using the following small plugin:
It is called directly beneath the <img> element:
This way it works fine with the current versions of Firefox and IE. I did not test other browsers or versions yet. I tried to call it in $(document).ready but then IE might display the picture shortly before it is hidden and faded-in.
Since I am not 100% happy with having the code in the middle of the HTML and with depending on the timing of execution to avoid flickering I wanted to ask for other solution or best practices to achieve what I would like to do.
Which is considered best practice?
View 3 Replies
Jun 29, 2007
myDiv.onmouseover = doThis;
...or something else?
View 5 Replies
May 10, 2011
My question is, would you recommend just putting it in SCRIPT tags in the header, or should I create thispage.js so that the code is separated into another file? It slows the request because the browser has to ask for another external file, but keeps code out of the HTML doc.
View 8 Replies
Jun 18, 2011
What's the "best" way to write that onclick method in its current context? I can think of a few ways to do it -- but they all seem fairly "dirty."
Have I gone stupid?
View 1 Replies