...

View Full Version : Drop down menu...help :'(



jonnybinthemix
05-06-2006, 11:13 PM
hey guys,

I have been trying to put an menu option on a form, with 3 options in it.

Then i need 3 scripts that will upload an image to the server (php) ((no problem))

However, i want each script to be linked with the option in the drop down list.

I.E.. Browse to select me.jpg, then select upload to: album1, or album2, or album 3 (depending on users choice) then it will put the relevent script.php in the <form action=" "

A little birdie told me that this may be possible using javascript, however my js is not advanced enough to know how..

Does anybody have any ideas if this is possible with JS, and if so, how would i go about coding it?

Any help is more than apreciated, thanks

Jon

vwphillips
05-07-2006, 10:29 AM
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
<title></title>
<script language="JavaScript" type="text/javascript">
/*<![CDATA[*/

fred='Album1';
/*]]>*/
</script></head>

<body>

<form action="http://wwww.What'+fred+'ever.php" >
<select onchange="fred=this.value;" >
<option value="Album1" >Album 1</option>
<option value="Album2" >Album 2</option>
<option value="Album3" >Album 3</option>
</select>

</form>
</body>

</html>

jonnybinthemix
05-07-2006, 08:13 PM
hi mate,

thanks very much for you help.

Could you explain your code a bit though as im not sure if i understand all of it?

Thanks

jon

vwphillips
05-07-2006, 10:16 PM
<form action="http://wwww.What'+fred+'ever.php" >
<select onchange="fred=this.value;" >
<option value="Album1" >Album 1</option>
<option value="Album2" >Album 2</option>
<option value="Album3" >Album 3</option>
</select>

the onchange event changes the value of variable fred to the selected option value

the url uses the variable fred to costruct the text of the url

jonnybinthemix
05-08-2006, 12:29 PM
that makes sense to me now, however, i cant get it to work :(

have i used your code correctly here:


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>FartingFish.com - the online photo album</title>
<link rel="stylesheet" type="text/css" href="style.css" />

<script language="JavaScript" type="text/javascript">
/*<![CDATA[*/

fred='skatingupload';
/*]]>*/
</script>

</head>
<body>

<div id="container">
<div id="logo">
<img src="logo_main.jpg" alt="mail logo">
</div>

<div id="menu">
<ul>
<li><a href="index.php">Home</a></li>
<li><a href="skating.php">Ice Skating</a></li>
<li><a href="pool.php">Pool</a></li>
<li><a href="random.php">Random Images</a></li>
<li><a href="video.php">Videos</a></li>
<li><a href="upload_image.php">Upload an Image</a></li>
<li><a href="#">Contact Me</a></li>
</ul>
</div>
<br>
<br>
<div id="description">
<i>Welcome to the upload section of the Photo Album, here you can
can upload your photo's. Please feel free to upload your images
for everyone to view.</i>
</div>
<br>
<form action="http://wwww.fartingfish.com/'+fred+'.php" method="post" enctype="multipart/form-data">
<div id="form">

<label class="boldital" for="file">Image:</label>
<input type="file" name="file" id="file">
<br>
<br>
<b><i>Which album would you like to upload your image to?</i></b>
<br>
<select onchange="fred=this.value;" >
<option value="skatingupload" >Ice Skating</option>
<option value="poolupload" >Pool</option>
<option value="upload" >Random Images</option>
</select>

<br>
<br>
<input type="submit" id="upload" name="upload" value="Upload">
</div>
<br>


</div>
</body>
</html>

Thanks again

jon

jonnybinthemix
05-08-2006, 09:12 PM
anyone got any ideas??

Jon

vwphillips
05-08-2006, 09:38 PM
this should be better


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>FartingFish.com - the online photo album</title>
<link rel="stylesheet" type="text/css" href="style.css" />

<script language="JavaScript" type="text/javascript">
/*<![CDATA[*/

function ChangeAction(obj){
obj.form.action='http://www.fartingfish.com/'+obj.value+'.php';
}

/*]]>*/
</script>

</head>
<body>

<div id="container">
<div id="logo">
<img src="logo_main.jpg" alt="mail logo">
</div>

<div id="menu">
<ul>
<li><a href="index.php">Home</a></li>
<li><a href="skating.php">Ice Skating</a></li>
<li><a href="pool.php">Pool</a></li>
<li><a href="random.php">Random Images</a></li>
<li><a href="video.php">Videos</a></li>
<li><a href="upload_image.php">Upload an Image</a></li>
<li><a href="#">Contact Me</a></li>
</ul>
</div>
<br>
<br>
<div id="description">
<i>Welcome to the upload section of the Photo Album, here you can
can upload your photo's. Please feel free to upload your images
for everyone to view.</i>
</div>
<br>
<form action="http://www.fartingfish.com/skatingupload.php" method="post" enctype="multipart/form-data">
<div id="form">

<label class="boldital" for="file">Image:</label>
<input type="file" name="file" id="file">
<br>
<br>
<b><i>Which album would you like to upload your image to?</i></b>
<br>
<select onchange="ChangeAction(this);" >
<option value="skatingupload" >Ice Skating</option>
<option value="poolupload" >Pool</option>
<option value="upload" >Random Images</option>
</select>

<br>
<br>
<input type="submit" id="upload" name="upload" value="Upload">
</div>
<br>


</div>
</form>
</body>
</html>

jonnybinthemix
05-08-2006, 09:46 PM
:D:D:D:D

Works perfect mate :)

Only other thing thats niggling me with it is the upload scripts i have wont upload to both directories as it thought they would, i know its php and im in the js forum, but i thought maybe you are an expert in many fields! ;)

Here goes, this is what i have:


<?php

$uploaddir="gallery";
$uploaddirl="largegallery";

if (is_uploaded_file($_FILES['file']['tmp_name']))
{
move_uploaded_file($_FILES['file']['tmp_name'],$uploaddir.'/'.$_FILES['file']['name']);
move_uploaded_file($_FILES['file']['tmp_name'],$uploaddirl.'/'.$_FILES['file']['name']);
}
print "Image Uploaded Successfully"

?>

my assumption was that if i add another var with another directory and then moved the file twice it would save the file to 2 directories??

After realising it doesent work, i thought maybe the tmp file is deleted as soon as its moved once? is there a way of saving it to 2 directories?

Thanks again

Jon



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum