JavaScript

  Matt45 20:35 23 Jul 04
Locked

I am writing my own content management system for my website. I've got a script which uploads images - that's fine. For each article, I want an image associated with it. I want to either enter the filename of the image in a text box on a form or select it from the uploaded images. I wrote a script that displays all the uploaded images but now I can't figure out how to write the script to fill the text box with the image name. Next to the text box I have a link called Browse which opens a page in a new window with all the uploaded pictures in. What I need to know is what the script would be that means when an image is clicked, the address of that image is entered into the text box on the form in the other window. I have the url of the image in a variable on the PHP page called $url.

Any help is appreciated. Thanks

  javaBalls 17:30 25 Jul 04

It's hard to provide answer.

Maybe if you post some of your code then I might be able to identify a solution.

  robert-259135 13:35 29 Jul 04

<input type="button" Value="NAME" style="font-family:verdana" style="color:ffffff" style="background:#ff0033" style="font-size: 14pt" ONCLICK="window.open('click here URL YOU WANT THE BUTTON TO GO TO')">



change the word name with your page name then put in the url to the page you want the link to goto ..hope this is what you ment

  Taran 22:26 29 Jul 04

Several things spring to mind here. The first is, do you really want the address of the image entered into the text box ? One of the joys of scripting a CMS is that you get to hide the filepath of images or downloads which can help prevent leeching.

Second, why JavaScript ? Unless you are very, very careful, JavaScript will work on most browsers most of the time. PHP on its own or combined with MySQL will work on all browsers, as long as you don't completely mess up the HTML it outputs.

The way I normally do this is to write an upload script that renames the file when the file reaches the web server, then the filename is recorded into the MySQL database. Renaming is usually only necessary where many images need to be managed from specific sources. If you don't need a rename function, don't use it. I only use MySQL to store images if there are very few, but if there are loads I store the filename and path. The browse function pulls the filename from the database and a request to view the image pulls the image into the browser by calling its path. I tend to use $img_src for the filename and $img_alt for the ALT descriptive tag, both pulled out of the database using SQL.

You seem to have a lot of ideas and I wish you every success with them. I wonder though, if you have a firm plan of what goes where, when and why. A CMS is, by its very nature, no small undertaking and if you want an image to accompany an article I can see several golden opportunities for document linking, logical filename structures and so on.

My largely unhelpful reply in this case is to sit back, stop coding, get a pen and paper and plan in minute detail what you want. If you get the planning all thoroughly prepared with a system specification, design brief, data flow diagrams and so on, the coding becomes naturally easier since you have a model to work to. I may be doing you an injustice - perhaps you have already done that and you are merely struggling with the actual code for certain functions.

I'd seriously question why you want a JavaScript solution though.

  Taran 22:27 29 Jul 04

Some links may have been helpful:

click here

click here

Both are PHP based and should point you in the right direction.

Good luck with it.

This thread is now locked and can not be replied to.

Best phone camera 2016/2017: Galaxy S7 vs iPhone 7 vs Google Pixel vs HTC 10 Evo vs OnePlus 3T vs…

1995-2015: How technology has changed the world in 20 years

These are the Best Christmas Ads and Studio Projects of 2016

Super Mario Run preview | Hands-on first impressions of Super Mario Run: Mario's iPhone & iPad…