| :: |
| Author |
Message |
BigfootDepot
Joined: 27 Apr 2005
Posts: 916
Location: Northwest Ohio
|
| Posted: Sun Jul 04, 2010 9:33 pm Post subject: Need HELP with HTML and simple JavaScript |
|
|
I have spent about 30 hours on this and I just can't seem to get it.
I have a simple web site that I use for the softball team I coach.
During the season, we take pictures and I would like to make the pictures available for everyone to see.
I having been doing HTML for a few years and I have it down on creating a page, formatting, text, insserting images from the image host, links ..... most of this stuff gives me no problems.
But the JavaScript I am trying to place in the HTML code just ain't doing it and I can't figure out what I need to do.
What I want to do seems like it would be very simple.
I presently have a page that has a little heading at the top.
Under the heading is a table with 3 columns.
The left column has a button that says <<Prev>>.
I can name my images on the Image host as img_1.jpg, img_2.jpg, img_3.jpg, ......... img_23.jpg
When the page loads, it displays img_1.jpg.
I want that when you click on the NEXT button it displays img_2.jpg.
NEXT again would display img_3.jpg.
If you click on the PREV button, it would then display img_2.jpg
What I have so far is:
--- I have a couple variables defined: one for the current image number count and then one for the largest image number count (so I don't try and display img_24.jpg if there are only 23 images).
--- I have 2 functions defined in the <HEAD> section: one named addone to increment the image count by 1, and then named subone to decrement the image count by 1. The function for adding 1 has the logic to prevent going too high. The function for subtracting 1 has the logic to prevent it from going below the number 1.
--- For the two buttons, on the PREV button I have the "onclick" performing the subone function and the NEXT button the "onclick" performs the addone function.
--- For testing purposes as I moved along, I have the two functions, addone and subone, adjusting the image count up or down as needed and then displaying an ALERT box showing the counters.
THIS ALL WORKS.
If I open the .htm page in my browser, the headings are there, the buttons are there, the first picture is there. If I click on PREV or NEXT button, a little box opens up and shows the value in my counters, and the values are what I want.
This is where I am now stuck.
1. Within the <img tag I have src="http://my.web.com/bigfootdepot/img_0.jpg"
What is the syntax needed so I can modify the image number for displaying the next picture? My variable counter is imgcount, so how do I get it to use something like
src="http://my.web.com/bigfootdepot/img_imgcount.jpg"
2. Once the path for the new image is modified, how do I get the new image requested to display? The table with the 3 colums is defined within a <FORM>. Is there a form.write command or something like that?
Any help would be greatly appreciated.
If more info is needed, I could copy+paste the actual HTML could I have so far.
What I have is working as far as displaying the ALERT for testing, but how do I get it to display the new images for NEXT or PREV? |
|
| Back to top |
|
mojavelyn
Joined: 25 Feb 2005
Posts: 8084
Location: Mojave Desert CA 120 miles from civilization
|
| Posted: Mon Jul 05, 2010 12:53 am Post subject: |
|
|
try this one... img src="http://my.web.com/bigfootdepot/img_0.jpg"
But I don't know about image count... |
|
| Back to top |
|
BigfootDepot
Joined: 27 Apr 2005
Posts: 916
Location: Northwest Ohio
|
| Posted: Mon Jul 05, 2010 1:10 am Post subject: Re: Need HELP with HTML and simple JavaScript |
|
|
I have the quotes around it. I guess I just didn't put them in when I typed up the question.
I will change the OP so no one else gets confused.
Thanks |
|
| Back to top |
|
mojavelyn
Joined: 25 Feb 2005
Posts: 8084
Location: Mojave Desert CA 120 miles from civilization
|
| Posted: Mon Jul 05, 2010 1:55 am Post subject: |
|
|
| but are you using img src and not just src? |
|
| Back to top |
|
BigfootDepot
Joined: 27 Apr 2005
Posts: 916
Location: Northwest Ohio
|
| Posted: Mon Jul 05, 2010 2:01 am Post subject: |
|
|
mojavelyn wrote (View Post): › docWrite("quote")but are you using img src and not just src?
Yes ..... it's <img src="-----------------> |
|
| Back to top |
|
mojavelyn
Joined: 25 Feb 2005
Posts: 8084
Location: Mojave Desert CA 120 miles from civilization
|
| Posted: Mon Jul 05, 2010 2:12 am Post subject: |
|
|
hey, its been a long day.
Does this help?
http://www.thefreecountry.com/webmaster/htmleditors.shtml |
|
| Back to top |
|
BigfootDepot
Joined: 27 Apr 2005
Posts: 916
Location: Northwest Ohio
|
| Posted: Mon Jul 05, 2010 2:25 am Post subject: |
|
|
mojavelyn wrote (View Post): › docWrite("quote")hey, its been a long day.
Does this help?
http://www.thefreecountry.com/webmaster/htmleditors.shtml
I will have to look at that one a little more.
I already have an HTML editor ----- FrontPage 2000.
It's just a matter of gettting the JavaScript mingled with the HTML to make it all work. |
|
| Back to top |
|
mojavelyn
Joined: 25 Feb 2005
Posts: 8084
Location: Mojave Desert CA 120 miles from civilization
|
| Posted: Mon Jul 05, 2010 2:35 am Post subject: |
|
|
| I use frontpage and another, but don't do javascript. it has funny reactions with php sites. |
|
| Back to top |
|
BigfootDepot
Joined: 27 Apr 2005
Posts: 916
Location: Northwest Ohio
|
| Posted: Mon Jul 05, 2010 9:53 pm Post subject: Re: Need HELP with HTML and simple JavaScript |
|
|
I have made great strides with my web page in the last day, thanks to this thread and some PMs that were sent to me.
I have created variables and functions so when I click on the PREV or NEXT button I can send an ALERT that displays the correct URL for the previous or next image I want displayed.
The HTML for the image when the page loads say:
{img src="http://my.web.com/bigfootdepot/bcreek2010_img_1.jpg" name="magic_img"}
(note -- {=<and> for purposes of getting the code to display)
When I click on the NEXT button, it performs a function that correctly creates what I want for the location in the variable imgurl for the src= value to be:
"http://my.web.com/bigfootdepot/bcreek2010_img_2.jpg"
( note -- the double-quotes are contained in the variable imgurl)
The last thing I do in the function is:
document.magic_img.src = imgurl
When I test it, the page loads with the 1st image, and then when I click on NEXT, the original image disappears and I get the X where the image should be. If I right-click on the X to get the properties, it appears to try to be locating the image in my TEMP directory on my PC as opposed to the location on the image host.
I have a feeling it has to do with relative or absolute location of the image ..... so I'm now digging to try and figure out how I can make it use absolute, thereby retrieving the images from my image host instead of looking on someones harddrive.
Any suggestions anyone ???
THANKS in advance. |
|
| Back to top |
|
BigfootDepot
Joined: 27 Apr 2005
Posts: 916
Location: Northwest Ohio
|
| Posted: Mon Jul 05, 2010 11:43 pm Post subject: Re: Need HELP with HTML and simple JavaScript |
|
|
I GOT IT !!!
The variable that contains the URL of the location of the next image does NOT have to have the double-quotes in it. SO I didn't need the double-quotes within the value of the variable, I guess HTML just assumes the double-quotes are there and you are just changing the location inside ..... |
|
| Back to top |
|
things4u
Joined: 21 Jan 2007
Posts: 1331
|
| Posted: Tue Jul 06, 2010 1:58 am Post subject: |
|
|
| SO happy you got it and the info helped |
|
| Back to top |
|
| |