Sunday, December 27, 2009

Help with incorrect html coding?

I currently use the code below in a html file. The idea is to select a file from a directory, with directory based on a year and file based on a month. The directory and file are numbers.





%26lt;script language=';JavaScript';%26gt;


getyear()


getmonth()


%26lt;/script%26gt;


%26lt;script language=';vb';%26gt;


Let var $year = getyear()


Let var $month = getmonth()


Let var $calendar = ';$year';+';/';+';$month';


%26lt;link href =';/Calendar/$calendar.html';%26gt;


%26lt;/script%26gt;





The problem is this code does not work. Does anyone have a suggestion to correct it?





Thanks





MichaelHelp with incorrect html coding?
%26lt;script language=';JavaScript';%26gt;


var d = new Date();


var m = d.getMonth()+1;


var y = d.getYear();


document.write('%26lt;link href=';/Calendar/' + y + '/' + m + '.html';%26gt;');


document.write('%26lt;a href=';/Calendar/' + y + '/' + m + '.html';%26gt;Click here%26lt;/a%26gt;');


%26lt;/script%26gt;





The functions ';getMonth'; and ';getYear'; need to be called from a ';Date'; object.





The dollar sign ($) is not used for variable names in JavaScript.





Your code is using ';link'; which will not display anything on the page, so I added the ';a'; tag in case you were looking to make a clickable link.Help with incorrect html coding?
Simply saying ';code doesn't work'; is not enough. The best way to ask for coding help is to, of course, show your code, but also explain the outcome you were expecting, and the outcome you actually got.





By looking at your code, it looks like $calendar is being set to ';$year/$month'; literally. I can see where this is breaking your link. $calendar should be set like this:





$calendar = $year+';/';+$month





Get rid of the quotes around $year and $month, otherwise they will be seen as strings, not variables. The way you have it now, you are concatenating the strings ';$year';, ';/';, and ';$month';.
You're mixing running of JavaScript and VlB.net script. One is server-side, the other is client-side. Each can send data to the other, but only by making trips back and forth between the server and the client.





Ron
  • hair shampoo
  • printer toner
  • triamcinolone cream
  • facial scrub
  • No comments:

    Post a Comment