|
well thanks mate, cheers
but i have edited your code a bit to just meet that edge:
function redir(ic) {
ic++;
switch(ic) {
case 1:
$('#text1').text(s0);
break;
case 2:
$('#text1').text(s1);
break;
case 3:
$('#text1').text(s2);
break;
case 4:
$('#text1').text(s3);
ic = 0;
break;
default:
$('#text1').text(s0);
}
setInterval("redir("+ic+")", 500);
return 0;
}
</script>
|
|
|
|
|
Shantanu Gupta 1337 wrote: but i have edited your code a bit to just meet that edge:
You have edited your own code which I had modified.
If it were my code it would look like this ...
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script>
var redir = (function(){
this.ic = 0;
this.ar = arguments;
return function(){
if(++ic == ar.length){ic = 1;};
$('#'+ar[0]).html(ar[ic])};})
("text1","Redirecting","Redirecting.","Redirecting..","Redirecting...")
</script>
</head>
<body>
<div id="text1"></div>
</body>
<script>
setInterval(redir,500);
</script>
</html>
modified on Sunday, August 1, 2010 4:40 PM
|
|
|
|
|
I am trying to, on my homepage show just a sample of what is on my website using a certian number of images. The code I have already is (found code online):
Code in header:
<SCRIPT LANGUAGE="JavaScript">
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http:
<!-- Begin
var theImages = new Array()
theImages[0] = 'Images/Nepticulidae/Stigmella_Aurella/Stigmella_aurella_Adult1.jpg'
theImages[1] = 'Images/Lasiocampidae/Drinker/Drinker_Moth_Adult_Male1.jpg'
theImages[2] = 'Images/Geometridae/Pale%20Brindled%20Beauty/Pale_Brindled_Beauty_Tree.jpg'
theImages[3] = 'Images/Noctuidae/Cuculliinae/Early%20Grey/earlygrey_Rossa.jpg'
theImages[4] = 'Images/Noctuidae/The%20Satellite/Satellite_Yellow_Stigma1.jpg'
theImages[5] = 'Images/Nymphilidae/Painted_Lady/Painted_Lady_Road.jpg'
theImages[6] = 'Images/Nymphilidae/Small_Heath/Small_Heath_Resting1.jpg'
theImages[7] = 'Images/Nymphilidae/Meadow_Brown/Irish/Meadow_Brown_Flower.jpg'
theImages[8] = 'Images/Nymphilidae/Owl%20Butterflys/Caligo_Menom/Owl_Butterfly_Resting.jpg'
theImages[9] = 'Images/Pterophoridae/Stenoptilia_pterodactyla/Stenoptilia_pterodactyla_Adult1.jpg'
theImages[10] = 'Images/Pyralidae/Chrysoteuchia%20culmella/Chrysoteuchia_culmella_Adult2.jpg'
theImages[11] = 'Images/Sphinigidae/Eyed_Hawk_Moth/Eyed_Hawk_Moth_Resting1.jpg'
theImages[12] = 'Images/Tortricidae/Tortricinae/Syndemis%20musculana/Syndemis_musculana_Mating.JPG'
theImages[13] = 'Images/Unusual%20Moths/Tony%20Kingston/Popular%20Hawkmoth/Popular%20Hawkmoth%201.jpg'
theImages[14] = 'Images/Unusual%20Moths/Roger%20Skeen/Oleander_Hawk_Moth1.jpg'
theImages[15] = 'Images/Unusual%20Moths/Roger%20Skeen/Bastilla_crameri.jpg'
var j = 0
var p = theImages.length;
var preBuffer = new Array()
for (i = 0; i < p; i++){
preBuffer[i] = new Image()
preBuffer[i].src = theImages[i]
}
var whichImage = Math.round(Math.random()*(p-1));
function showImage(){
document.write('<img src="'+theImages[whichImage]+'">');
}
</script>
Code placed where I want the images displayed:
<SCRIPT LANGUAGE="JavaScript">
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http:
<!-- Begin
showImage();
</script>
Because my website is about butterflies and moths, when the image of a species appears, I would like below the image text saying what the species is and when you click the text (want text to be hyperlink), it takes you to a page about that species, target frame for the hyperlink is _self
Anyone know how I could do this?
David McCormick
In the end we're all just the same
|
|
|
|
|
Dave McCool wrote: I would like below the image text saying what the species is and when you click the text (want text to be hyperlink)
it's like this ...
Dave McCool wrote: var theImages = new Array()
Dave McCool wrote: theImages[0] = 'Images/Nepticulidae/Stigmella_Aurella/Stigmella_aurella_Adult1.jpg'
theImages[1] = 'Images/Lasiocampidae/Drinker/Drinker_Moth_Adult_Male1.jpg'
var theImages = new Array() ;
var theText = new Array() ;
var theLink = new Array();
theImages[0] = 'Images/Nepticulidae/Stigmella_Aurella/Stigmella_aurella_Adult1.jpg';
theText[0] = "This is a butterfly?";
theLink [0]= 'HTMLfiles/Nepticulidae/Stigmella_Aurella.html';
theImages[1] = 'Images/Lasiocampidae/Drinker/Drinker_Moth_Adult_Male1.jpg';
theLink[1] = 'HTMLfiles/Lasiocampidae/Drinker.html';
theText[1] = "This butter is fly?"
Dave McCool wrote: function showImage(){document.write('<img src="'+theImages[whichImage]+'">');}
function showImage(){
document.write('<table><tr><td>');
document.write('<img src="'+theImages[whichImage]+'">');
document.write('</td></tr><tr><td>');
document.write('<a href =' + theLink[whichImage] + '>');
document.write(theText[whichImage]);
document.write('</a>');
document.write('</td></tr></table>');
}
this is very close to what you are asking
|
|
|
|
|
I have two calendar extenders.FromDate and ToDate.I have to validate it by using javasript.FromDate wont become greter than ToDate.when fromdate entered is greater than todate,a messagebox will appear..Pls help me
|
|
|
|
|
Please don't cross post. Posting at multiple forums is considered rude. Pick one forum and stick to it.
Cross Post[^]
|
|
|
|
|
Sorry for my mistake..I dont repeat this
Thanks
|
|
|
|
|
I have a ajax tool calendarExtendarFromDate,imgFromDate,textBoxFromDate,calendarExtendarToDate,imgToDate and textBoxToDate,When a date is selected from calendarExtendarFromDate,that date is displayed in textBoxFromDate.Likewise in the case of calendarExtendarToDate.Here is the source code:
--------------------------------------------------------------
<asp:UpdatePanel ID="UpdatePanel1" runat="server"> <asp:TextBox ID="txtFromDate" runat="server" ReadOnly="True"> <img id="imgFromDate" runat="server" src="~/images/calendar.png" alt="~/images/calendar.png"/>
<cc1:CalendarExtender ID="CalendarExtenderFromDate" runat="server" CssClass="cal" TargetControlID="txtFromDate" PopupButtonID="imgFromDate"/> </cc1:CalendarExtender
<asp:TextBox ID="txtToDate" runat="server" ReadOnly="True" Enabled="False"<img id="imgToDate" runat="server" src="~/images/calendar.png" alt="~/images/calendar.png"/> <cc1:CalendarExtender ID="CalendarExtenderToDate" runat="server" OnClientDateSelectionChanged="CheckForFutureDate" CssClass="cal" TargetControlID="txtToDate"PopupButtonID="imgToDate"/>
-------------------------------------------------------------
I have radiobuttons..When the radiobutton between is clicked,then only calendarExtendarToDate is enabled.otherwise it becomes in disabled state..I wrote code in jscript as below:
function validate()
{
document.getElementById("imgToDate").disabled=false;
document.getElementById("txtToDate").disabled=false;
}
//call this function in .aspx.cs as below:
rbBetween.Attributes.Add("onClick", "return validate()");
textbox is disabled.When between radio is clicked,then only enabled.But calendarextendar disabled didnt work.Pls help me...
|
|
|
|
|
Please don't cross post. Posting at multiple forums is considered rude. Pick one forum and stick to it.
Cross Post[^]
|
|
|
|
|
..may as well be me!
This is perhaps a little cheeky to ask, but hey... my JavaScript skills are functional (shall we say)
but I've never really mastered it... in particular, the use of arrays....
I have a FileUpload control, fu2, with the following attribute added in code behind:
fu2.Attributes.Add("onchange", "checkFile(this)")
which call this verification function in my JavaScript file:
function checkFile(what){
var source=what.value;
if (source!='') {
var i = source.lastIndexOf("\\");
var j = source.lastIndexOf(".");
var fName = source.substring(i+1,j);
var ext=source.substring(source.lastIndexOf(".")+1,source.length).toLowerCase();
if ( ext=='doc' || ext=='docx' || ext=='pdf' || ) {
var regex = /^[A-Za-z0-9_ -]{1,50}$/;
if (!regex.test(fName)) {
alert('The file name contains illegal characters, or is too long\nPlease re-name the file using only alphanumeric charcters, hyphens, spaces and underscores\nand restrict it to a maximum of 50 characters\n' + fName);
}
} else {
alert('Please upload only files of the following types:\n .doc, .docx, .pdf');
}
}
}
As you can see, this attempts to limit both the file types the user can upload, and also the file name.
And actually, it all works well enough - but I know it could be written so much better...
I feel that the "list" of allowable file types should be an array, and the test made
against that, as well as the alert message built out of it - thus making the code that
much easier to maintain if the list changes. Arrays.. hmm.. this is where I get stuck...
plz, it's not urgentz, but if anyone is feeling generously inclined....
|
|
|
|
|
NeverHeardOfMe wrote: I feel that the "list" of allowable file types should be an array, and the test made
against that
<html><head><script>
var fileTypeAllowed = (function(){
var ar = arguments;
return function(arg){
for(var i = ar.length;i--;){
if(arg == ar[i]){return true;}}
return false;
};})('doc','docx','pdf');
alert(fileTypeAllowed('docx'));
alert(fileTypeAllowed('docxa'));
</script>
</head>
<body>
hi
</body></html>
modified on Tuesday, September 14, 2010 12:44 PM
|
|
|
|
|
See... I knew it would be obvious....
Thanks
(Sorry for not marking your answer as "Good" - done now!)
modified on Friday, July 23, 2010 4:19 AM
|
|
|
|
|
NeverHeardOfMe wrote: See... I knew it would be obvious....
Thanks
There is nothing obvious about that code
|
|
|
|
|
Just to let you know, you spelt characters wrong in the alert() function
NeverHeardOfMe wrote: only alphanumeric charcters, hyphens, spaces
|
|
|
|
|
Ta.. I love typos - I do them all the time!
|
|
|
|
|