picture update.

Javascript coding ..

Moderators: macek, egami, gesf

webbhost
New php-forum User
New php-forum User
Posts: 21
Joined: Sun Jul 04, 2004 3:32 pm
Location: uk
Contact:

picture update.

Postby webbhost » Thu Sep 09, 2004 3:41 pm

Hiya, i want a picture on my webpage to be updated accoring to a form.

This is what i have but it doesnt want to work.

Code: Select all

<form action="addcategorynow.php" method="POST" name="theform">
<select name="catpic" onChange="javascript:displaypicture(this)">
<option>animal.jpg</option>
<option>buildings</option>
</select>   
</form>


In the header section of my page. i have this...


Code: Select all

<Script language="javascript">
function displaypicture(myForm){
document.picviewer.src = "http://www.falcon-eye.co.uk/galleryimages/categorypics/" + document.theform.catpic.value

}
</script>



Now it doesn't want to work, does anybody know why? The address of the image vhanges from http://www.falcon-eye.co.uk/galleryimag ... spacer.jpg

to

http://www.falcon-eye.co.uk/galleryimages/categorypics/

I cant see whats going wrong.

User avatar
ruturajv
php-forum Super User
php-forum Super User
Posts: 1280
Joined: Sat Mar 22, 2003 9:42 am
Location: Mumbai, India
Contact:

Postby ruturajv » Thu Sep 09, 2004 7:44 pm

do such kind of stuff...

Code: Select all

<script type="text/javascript">
function change_image() {
  if (document.forms['formname'].selectname.value == somevalue) {
    document.image['image1'].src = 'new path';
  }

}
</script>

<img src="the path" name="image1" />

..
..
<form>
..
<select onchange="change_image()">
..
</select>

webbhost
New php-forum User
New php-forum User
Posts: 21
Joined: Sun Jul 04, 2004 3:32 pm
Location: uk
Contact:

Postby webbhost » Fri Sep 10, 2004 3:29 am

i like the suggestion, but i aint too sure its that simple. All of the options for the select are imported throgh a database. They can be changed around etc.

- either way i just tried it and it wont work :S i got no idea why not. Really bugging me now.

User avatar
ruturajv
php-forum Super User
php-forum Super User
Posts: 1280
Joined: Sat Mar 22, 2003 9:42 am
Location: Mumbai, India
Contact:

Postby ruturajv » Mon Sep 13, 2004 8:20 pm

so what if all stuff is from the db..
remember you can write the javascript code in the php page....
inshort you can write a javascript array of the images path with php and get your stuff working


Return to “JavaScript”

Who is online

Users browsing this forum: Bing [Bot] and 1 guest