tgreer 189 Made Her Cry Team Colleague

Redsaber:

Technically, you CAN have such a script. It's just basic math, which JavaScript can do. The core issue though, is to KNOW a particular person's date of birth. How do you plan on storing that? Where? You have to store it somewhere that is accesible by your code.

If by "your code" we mean "code residing on and processed by your web server", then you would store everyone's birthdays on the server. You'd either use a database, such as MySQL, or an XML file.

If by "your code" we mean, JavaScript running on the browser, then you're faced with that fact that the birthday will have to be stored on the individual user's machine. The only way to do that is via a cookie.

The problem with that is, cookies don't last. The user can decide whether or not to accept cookies in the first place, and can arbitrarily delete them. For example, on my systems, the cookies don't last beyond the current browser session. So you could "remember" my date of birth for about 5 minutes, which renders your script useless.

That's why, in my opinion, my first answer is correct: "No.", there isn't a simple script to do this, and you'll need server-side code coupled with a persistent data store.

In that script you referenced, notice that a date is being passed into the "countup" function. You have to ask yourself, where did that date come from? It's hard-coded in the …

tgreer 189 Made Her Cry Team Colleague

alpha-foobar:

I don't always recommend the server-side option, but in this case, you'd have to agree, it is the most sensible approach.

The problem is the "so-and-so was born on this date". How do you know that? Where are you going to store that? With JavaScript, you'll have to store that information in a cookie, and hope that cookie is still there in a year.

So for this scenario, you'll need server-side code.

tgreer 189 Made Her Cry Team Colleague

No. You'll need server-side code, and a database in which to store the dates.

tgreer 189 Made Her Cry Team Colleague

Also, we can't stress enough the importance these days of using a correct doctype. A proper doctype will remove a large chunk of the cross-browser issues by forcing the browser to respect (to greater or lesser extent) a common DOM.

tgreer 189 Made Her Cry Team Colleague

Letscode: that isn't quite right. The "HTML" view in the VS.NET IDE isn't really HTML. It's ASP.NET code, or "aspx" code. Here you'll find the declaratives used by ASP.NET, along with the code-behind, to generate HTML. In other words, this isn't client-side code. What you see is still processed by the server.

tgreer 189 Made Her Cry Team Colleague

By "CSS" site, you mean that you have a "regular" web site/page that is formatted and styled with CSS, I assume.

Then, you have a forum. You want aspects from that forum to display in your regular site.

This is typically achieved through "RSS", which stands for "Really Simple Syndication". It's an XML format that turns content into "news" that can be consumed by other sites and applications.

Your 1st step is to research if your forum software already has RSS support.

Your 2nd step is to incorporate that RSS feed into your main site. You'll need to write some server-side code to do this (or incorporate something someone else has already written).

I would suggest you research the first step on your own. Then, ask further questions in a server-side coding forum. I suggest "PHP". The moderator of that forum, Troy, has written some PHP classes that will consume and display RSS feeds.

tgreer 189 Made Her Cry Team Colleague

Look at some of the code provided in thread:

http://www.daniweb.com/techtalkforums/thread29187.html

That shows how to RANDOMLY or SEQUENTIALLY alter images, but you should be able to adapt the code.

tgreer 189 Made Her Cry Team Colleague

JavaScript is client-side. So no, you cannot interact with files/processes on the server, via JavaScript. You need a server-side language for that. You need BOTH, server-side, and client-side, to develop robust web applications. I recommend PHP for server-side code.

What is the coding experience like? I can't really say... I've coded in so many languages, one is pretty much like the other. With two exceptions: PostScript, which is a page description language, so not relevant, and ASP.NET, which is Microsoft's Web language - I find that to be a horrible, tedious coding experience.

Think of JavaScript as adding richness to the user interface. It's also your first line of defense, for data validation. It "scripts" the UI. So, for example, imagine a user clicks a link to get more detail on a product. That detail may need to come (almost certainly) from the server, but it's JavaScript that creates the new "popup" window to display that data. In that detail page, the user may select something, which now needs to be added to a table on the parent page... only JavaScript can do that.

You may want the user to enter data in a certain format, but with JavaScript's regular expressions, you can ENFORCE that format.

There might be a preset spending limit for this user, which came from the server, and was stored in a JavaScript variable. JavaScript can keep a running total of what they've "spent" on the page, and popup a warning dialog …

tgreer 189 Made Her Cry Team Colleague

No, the DOM is not an external API. It is the page, seen from the point of view of JavaScript, and not just the page, but to some extent the browser itself.

HTML (I actually use a variant called "xhtml", a stricter, XML implementation of HTML) is the core bare-bones of what you see on the page.

Colors, positions, fonts, etc. are controlled by CSS. CSS styles are applied to XHTML elements. The browser interprets all of this. JavaScript is a client-side programming language for interacting with all of the above.

JavaScript can be used to reduce server round-trips. For example, if the user is entering an order, then can enter the quantity, and JavaScript can calculate the price, without having to go back to the server.

I use DHTML on my poetry site. I send all the poems to the page, and use JavaScript to selectively toggle the visibility based upon the links the user clicks, all without a server roundtrip. Those are just the tip of the iceberg.

On the other hand, you'll need a server-side language to truly develop a web application. Content is often driven by previous events, settings, and data, all of which is best accounted for in a server-side persistent data store (a database). PHP and ASP.NET (two popular server-side languages) interact with the database, and output DHTML (XHTML, CSS, JavaScript).

tgreer 189 Made Her Cry Team Colleague

Agreed. That message is unreadable.

tgreer 189 Made Her Cry Team Colleague

DHTML refers to the client-side manipulation of the Web Browswer DOM (Document Object Model), which includes HTML and CSS (Cascading Style Sheets), via JavaScript scripting.

There are IDEs, such as FrontPage and Dreamweaver. As an experienced coder, you won't need them.

What DHTML does NOT do, is provide any server-side functionality. For that you should look into (in your case) JSP (Java Server Pages), or PHP.

Server-side functionality includes, primarily, interaction with a database, and robust validation, file i/o, communication with other platforms, etc.

tgreer 189 Made Her Cry Team Colleague

Wonderful! Thanks for the posts, a_b.

tgreer 189 Made Her Cry Team Colleague

Yes, that's a client-side approach. You'd have to pre-load graphics. I think the server-side approach is more straightforward. And, as the O.P. was new to web development, I thought he should be exposed to server-side coding. But the thread would benefit from seeing a JavaScript code snippet, if you'd care to post one!

tgreer 189 Made Her Cry Team Colleague

Great! Then I suggest you ask the question in the appropriate server-side coding forum. If you're new to it, then I suggest PHP. PHP works by interspersing PHP tags with your HTML tags. When a user browses to a PHP page, the server first interprets the PHP.

So to generate an alternate image, you might have something that looks like:

<img src="<?php $myVariableImage ?>">

The trick, then, is to write PHP code that changes the value of the $myVariableImage string. So, armed with that little bit of foreknowledge, I suggest you go to the PHP forum and ask some questions there.

tgreer 189 Made Her Cry Team Colleague

It depends. The easiest way is with server-side code. You can't do it with plain HTML.

tgreer 189 Made Her Cry Team Colleague

You can do this a variety of ways. To give you the best answer, we need to know more about you and your capabilities.

For example, do you do any server-side coding at all? PHP, for example? Or do you want to do this all with client-side code?

tgreer 189 Made Her Cry Team Colleague

I say we all stop using .NET in any capacity. That'll make things easier.

Seriously, though, whatever else you decide, ASP.NET needs to be split out as a separate forum. It is such a weird way to do web development, and so many ASP.NET developers come to it without knowing the fundamentals of client-side development, so get into unique situations. Those situations don't have anything to do with the IDE or the language, but with the ASP.NET methodology.

tgreer 189 Made Her Cry Team Colleague

Hmmm... I wouldn't think to post a question about Visual Studio, in such a forum.

Mabye combine .NET Framework, C#, and VB.NET in a "Visual Studio.NET devleopment" forum?

tgreer 189 Made Her Cry Team Colleague

Probably not. I can imagine someone having a non-programming question about the .NET Framework, but is that worth an entire dedicated forum? I don't think so.

tgreer 189 Made Her Cry Team Colleague

The problem with C# and VB.NET, is that either language can be used for either web development or windows development. So, I think the compromise of having ASP.NET under Web Devleopment, and C#/VB.NET under Software Development, is not a bad one.

The only issue is that I'm a C# developer. So when people ask ASP.NET questions using VB.NET code snippets, I can only answer the question "in general".

Also, I'm sure that there are a lot of C#/VB.NET posts that really should go in the ASP.NET forum. But, that's why the site has moderators... to move such threads.

tgreer 189 Made Her Cry Team Colleague

Dani,

I honestly never saw any of the screenshots. Where were they posted? Yes, the ads totally overwhelm the content, and the navigation. The tabs at the top are fine, but way too small. The side navigation panels are basically useless... too tiny, and overwhelmed by ads.

I still can't find the JavaScript forum.

tgreer 189 Made Her Cry Team Colleague

Maybe this should go in the "Site Feedback" forum, I don't know.

Wow, I really don't like this style. Most of the navigational elements are WAY TOO SMALL.

Where did the JavaScript/DHTML forum go? I can't seem to find it anymore. It should be under Web Development.

So... I guess I'll let whoever finds it first moderate it, while I go get my eyes checked.

tgreer 189 Made Her Cry Team Colleague

In fact, I believe I was sunk by just such a well-wisher. I don't have any proof, because Google refuses to disclose any details about the nature of the "invalid clicks".

What I think happened: I was at a coffee shop, moderating a poetry forum I used to run. Someone watching over my shoulder asked about the site. I told them I ran it, gave them the URL. Later that day, I noticed that an unusually high number of ads were clicked on that site.

I thought nothing of it. Google supposedly filters out repeated clicks (or so I thought). I expected an automatic correction. However, the very next day I got the infamous "invalid clicks" email, and was permanently disqualified from any future participation in the Adsense program.

However, the ads continued to run!! I wasn't earning any income from them, but Google certainly was. That strikes me as shady, SO, I removed all ads from the site, and permanently disqualified Google from publishing any ads on any of my sites. :)

tgreer 189 Made Her Cry Team Colleague

I'm not sure you can. I have fallen victim to this on one of my sites. Google will not disclose any details about what happened, who did it, what IP address, or the nature of the the infraction. Also, you are disqualified forever from future participation.

I think it should be Google's responsibility to police the invalid clicks. If the have such a certaintly that a click is invalid, which they evidently do, they should simply not register that click.

There is something then, profoundly flawed about the entire system.

tgreer 189 Made Her Cry Team Colleague

You use "self.opener.href.location = ".

So consider this link in your NEW page:

<a href="" onclick="self.opener.href.location = 'http://www.daniweb.com'";>

Which means "I'm a link to nowhere, but when you click me, set the location of the window that opened me to daniweb".

tgreer 189 Made Her Cry Team Colleague

I'm not sure what JavaScript/DHTML programming help we could give that would address the issue. "Java" and "JavaScript" are different things. You might try asking Yahoo! for help. You use the term "nth", which I understand to mean the last term in an indefinite series. I don't see how that makes sense in your message. Could you clarify, please?

tgreer 189 Made Her Cry Team Colleague

Java and JavaScript are not at all the same thing. If you're going to sites that require Java, you'll need to install a Java Virtual Machine. Search the web using that phrase.

If you're indeed having JavaScript problems, then try adjusting your Internet Security settings to "low" or "no security" as a test.

tgreer 189 Made Her Cry Team Colleague

I run a couple of low-volume, niche-specific sites. I run ads on them, from that big search engine company. I was recently told that my account was terminated for "invalid clicks", with no further details. I can only speculate that someone overenthusiastically clicked many, many ads. Searching the web a bit on the topic seems to indicate that's exactly what has happened to many, many others.

Suffice it to say, this irritates me mightily. Even though my account is evidently permanently "disapproved", the ads still show. Of course, they certainly have the right to ban anyone, for whatever reason they like. So be it.

I'd like to find an alternative. Is there an alternative? What I liked is that the ads were relatively low-key, and were (usually) on topic.

Thanks!

tgreer 189 Made Her Cry Team Colleague

That doesn't sound like a JavaScript problem. If it were, you'd get a little yellow "error" icon on the status bar (bottom of) your page, that mentioned "JavaScript error" or "page loaded but with errors", something like that.

Try the standard troubleshooting techniques: clear your cache, delete all your cookies, install all the latest OS and browser patches, stop using AOL, get FireFox, etc.

tgreer 189 Made Her Cry Team Colleague

You'll have to be a bit more specific. What sites "dont' work"? What doesn't "work" about them? What OS are you using? What browser? Version?

tgreer 189 Made Her Cry Team Colleague

You can still use hidden form elements. Just iterate through the Request.Form. I don't think you need Session or ViewState or tricks with PostBack. Just pass in a hidden form element value. If it's true, run your randomizer. If not, don't.

tgreer 189 Made Her Cry Team Colleague

We need to see your Page_Load routine. The Load event will indeed run each and every time. If there is code that should only run the first time the user visits the page, you isoloate that code within an "IsPostBack" conditional.

tgreer 189 Made Her Cry Team Colleague

That's exactly what's happening, because of all your submit buttons. You are submitting the form... that's not what you want to do. Change all the "submit" to "button".

tgreer 189 Made Her Cry Team Colleague

It's impossible to tell with only the code you showed. Nothing in those two lines would cause the text to disappear.

tgreer 189 Made Her Cry Team Colleague

The work-around is to set the style.property to "auto"?

tgreer 189 Made Her Cry Team Colleague

offsetHeight and offsetWidth were going to be my recommendations. I'll play around with this. So you have an initial height/width set by CSS, then you add content, presumably with JavaScript, and now want the new size of the DIV, correct?

tgreer 189 Made Her Cry Team Colleague

What properties are you using?

tgreer 189 Made Her Cry Team Colleague

browserCaps will also fix some of the HTML rendering issues. Panels will render as DIVs instead of Tables, etc. I've been meaning to write an article on browerCaps...

tgreer 189 Made Her Cry Team Colleague

I think you just need to modify the "startY" value in the script.

May I also give you a personal opinion? Don't do this... most users find scrolling elements like this extremely annoying. It won't get you any more clicks on your ads; in fact, the overall impact on click-throughs will probably be negative.

Just put them under your navigation buttons, and leave them there. Take as a guide professional sites, such as DaniWeb. Sophisticated users know what ads are, and what they are FOR. Waving them in my face isn't necessary.

tgreer 189 Made Her Cry Team Colleague

I would start on MSDN. Their articles on .NET programming generally include sample code.

tgreer 189 Made Her Cry Team Colleague

The problem is probably caused by "document.all", which is browser-specific. Do you have enough information to solve the problem yourself? You need to find some cross-browser JavaScript code to get/set cookies. You can probably find hundreds of examples by doing a web search.

Then, you need to pass that cookie's value into your select box, using the techniques found in the thread I referenced.

tgreer 189 Made Her Cry Team Colleague

When you say you don't know how to pass the QueryString, what exactly do you mean? I'm assuming that you know what the term "QueryString" means:

http://www.tgreer.com/resources.php?style=0

Everything after the question mark is the "QueryString". The JavaScript "location.search" object returns that to you. You have to parse it, using string functions, to get the particular value you need.

I have written something that does exactly what (I think) you're describing in another thread. It takes a value from the QueryString, and uses it to set the selected value in a Select/Option element. http://www.daniweb.com/techtalkforums/thread27049.html

But I'm guessing that you can't really USE a querystring, can you? Because that would imply you already know the value to pass in. You don't, do you? That's why you need to find a way to store the value in cookie, and get the value out of the cookie.

Is that correct?

tgreer 189 Made Her Cry Team Colleague

Yes, you can use a cookie to persist a value, but you'll still need JavaScript in order to set/get cookie values.

First, you need to test if your environment will let you include JavaScript elements. A simple alert will be a good test.

If you can post:

<script>window.alert("Hello world!");</script>

to your globaldhtmlcode property, does it work?

tgreer 189 Made Her Cry Team Colleague

Please post your question in a new thread.

tgreer 189 Made Her Cry Team Colleague

Make sure you use "Form1" instead of "myForm", for one thing. I don't see why you need two buttons. Or, why you need to set a Session variable. But that's all beside the point: it's saying it doesn't recognize "document.getElementById()"??

That is truly strange.

Take the "onlick=printMe();" out of your element declaration.

tgreer 189 Made Her Cry Team Colleague

Your error is because, in ASP.NET-world, the "onclick" attribute points to SERVER code. So the compiler is looking for a "printMe()" method in your code-behind page. In a way, then, yes - it's because you're using a web control.

That's why I wrote previously:

ASP.NET is NOT traditional web development, however. For one, your "onclick" code for the button control refers to server code. That would be your audit code that checked for "printed=YES".

To get a client-side click event registered to a server control, you have to do:

Code:

myServerControl.Attributes.Add("onclick","printMe();");

Now, to get the hidden form element's value, you can either 1) turn it into a server object by adding the runat=server attribute to the element's declaration, or 2) use the ASP.NET Request object.

tgreer 189 Made Her Cry Team Colleague

First, your print button can be an ASP.NET Web Server control, or not. Thinking it over, it might be good to use one, since then you can run both client and server-side code for it.

Let's talk about client-side first. You need to accomplish two things:

1) Open a print dialog box when the button is clicked.
2) Pass a value back to the server code that indicates the user clicked that button.

You accomplish the first task using the JavaScript window.print() method. You accompish the second task by setting the value of a hidden form element. You can do both tasks in a single JavaScript function. Here's a first attempt at what the code might look like:

<html>
<head>
<title>JavaScript Sample by tgreer</title>
<script type="text/javascript">
  function printMe()
  {
     window.print();
     document.getElementById("printed").value = "YES";
     document.getElementById("myForm").submit();
  }
</script>
</head>
<body>
  <form id="myForm">
    <input type="button" value="Print me" onclick="printMe();" />
    <input type="hidden" id="printed" />
  </form>
</body>
</html>

Now, in any traditional web development system, that would be pretty much it. The user would click the button, which would fire the script. The script opens the print dialog box, sets a hidden form element value, and submits the form.

The server code would parse the Request object to see if "printed=YES", and if so, do whatever it is you want to do.

ASP.NET is NOT traditional web development, however. For one, your "onclick" code for the button control refers to server code. That would be your audit code …

tgreer 189 Made Her Cry Team Colleague

Regarding ASP.NET Web Server Controls. They GENERATE html code.

So, an ASP.NET Web Server Button Control, creates an <input type="button"> element.

What is different about the Web Server Button Control, is that it has server-side events, properties, and methods.

So in Visual Studio.NET, you drag a button control over onto your form. Double-click it, and a code window appears. Any code you enter there will run ON THE SERVER.

What happens is, the user browses to the page, and IIS/ASP.NET renders a page for the user. The user sees a button, and clicks it. That particular click is a client-side event, and unless you code some JavaScript, nothing in particular happens. The form does submit, however, and that's where ASP.NET does a lot of house-keeping to remember that is has a "BUTTON", and that the BUTTON was clicked, and it must run the code you authored.

But none of that helps you with your problem, because printing is a client-side affair.

Really, in your scenario, you don't NEED a WebServer Button Control. A normal html button element, will work just fine:

<input type="button" onclick="window.print();" />

That is the basis of your solution.

tgreer 189 Made Her Cry Team Colleague

Any ASP.NET code executes on the server. So yes, you can print something, but it will print to your web server's default printer, if there is one. I assume you want to let the user print something from their browser. You need client-side code to that.

Once more, it's "JavaScript" - Java is a completely different animal. If you ask questions about "Java", you'll get answers about "Java", which won't be relevant.

I'd be happy to help you more, but we're off-topic. You should post a new question in the JavaScript/DHTML forum.

tgreer 189 Made Her Cry Team Colleague

You mean, you don't want to use "JavaScript". Java and JavaScript are not related to each other and have nothing in common.

You cannot know if a user actually printed. Printing is firmly in the hands of the user - a web developer cannot write code to force a user to print.

You can, however, create a "Print" button, and USING JAVASCRIPT, invoke the "window.print()" method when they press it. Again, USING JAVASCRIPT, you can author a hidden form variable, then submit the form. Your code-behind page would read the hidden form variable to know that the user clicked your "Print" button.

I know you said you didn't want "to use Java (sic)", but there is no way to do it otherwise. Web development involves both server-side and client-side scripting. If you ignore client-side scripting, you're only doing half the job!

If you need help with the JavaScript portions, post a question in the JavaScript/DHTML forum.