Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic update of HTML text field

Status
Not open for further replies.

hazg

Programmer
Dec 14, 2004
10
FR
Hello,

I am looking to update a html textfield from javascript. The script produces a slideshow of images which can be viewed via next/previous buttons or a automatically via a time delay. I want a description to be placed above each corresponding image that will change whenever the image does. The text field i want to update is:

document.write("<input type=text name=desc size=50 value=\"Description goes here\"> ");

Here is the function i have in the same chunk of script that works out which image it is but this is obviously overwriting everything else:

function description() {

if(current==0) {
document.write('Image One');
}
else if(current==1) {
document.write('Image Two');
}
else if(current==2) {
document.write('Image Three');
}
}

Any ideas would be great - Thanks
 
document.write("<input type=text ID="desc" name=desc size=50 value=\"Description goes here\"> ");



function description() {

if(current==0) {
label = 'Image One';
}
else if(current==1) {
label ='Image Two';
}
else if(current==2) {
label = 'Image Three';
}
document.getElementById("desc").value = label
}



Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

zen.gif
 
Here's a working example of a slideshow that I wrote and have used several times. It's simple and uses JS objects.

nancyandlee.tripod.com

Lee
 
Thanks a lot! I have sorted it now!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top