#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2001
    Posts
    7
    Rep Power
    0

    Javascript form help


    I've got a PHP script that will display an image with a title and caption using the following url... http://www.blah.com/image.php?image=...%20blah%20blah

    I'm creating a small javascript form that will generate that URL when the image URL, Title and Caption have been filled in on a form.

    The form has 4 input values, for example a, b, c and d.

    What I want is, when my Generate URL button is pressed, the values in a, b and c are copied into d along with the other stuff ("www.blah.com" "?image=" "&title=" "&caption=")

    I've tried using:

    PHP Code:
    function Generate()
    {
    document.forms[0].GenURL.value="http://www.blah.com/image.php?image=" URL "&title=" Title "&Caption=" Caption;

    But that doesn't work

    and am I correct in thinking escape() should be used on all the values to make them work as a URL?

    I'm kinda new at this

    Thx in advance
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2001
    Location
    Münster (Germany)
    Posts
    44
    Rep Power
    14
    I don't know anything about php, but you have to read out the form fields, did you?

    var URL = document.forms[0].URL.value;
    var Title = .....
    var Caption = ...

    The form fields name has to be URL to make this work, but I think you know this.

    Then you can put the value of the GenURL field together in the way you did.
    I'm sorry, but I don't know if you have to escape the whole thing to make it work as an URL.
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2001
    Posts
    7
    Rep Power
    0
    No, I didn't read the form fields, whoops

    I used the following function as the onclick event of my button and it works great.

    PHP Code:
    function Generate()
    {
    var 
    URL document.forms[0].URL.value;
    URL escape(URL
    var 
    Title document.forms[0].Title.value;
    Title escape(Title
    var 
    Caption document.forms[0].Caption.value;
    Caption escape(Caption)
    document.forms[0].GenURL.value"www.blah.com/image.php?image=" URL "?title=" Title "?Caption=" Caption;

    Thanx for the help

    -XeneX

IMN logo majestic logo threadwatch logo seochat tools logo