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

    Join Date
    Oct 2000
    Posts
    3
    Rep Power
    0
    I only want to do a function with an alert messagge in the following way:
    I mean I want to validate a Username field, so I get the value from a DB with PHP and then I want to pass that value to a JS function,

    eg.

    $name= from a DB;
    the form which I have to validate:
    <form name=form method="post" onsubmit="return validate()">
    ....
    ....
    how can I pass $name like a parameter in the validate() function? because "return validate(name)" doesn't work.

    thanks in advance.

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

    Join Date
    Jan 2001
    Location
    Canada / NZ / UK
    Posts
    73
    Rep Power
    14

    something like...


    <form name=form method="post" onsubmit="return validate(<? print $name ?>)">

    ?
    Highest Leader of UM
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 1999
    Location
    Denmark
    Posts
    83
    Rep Power
    15
    <form name=form method="post" onsubmit="return validate(this)">

    you just have to use "this" in the ()'s
    regds..
    -ulrik-
    ---------------------------------------
    Do or do not, there is no try....
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2000
    Posts
    54
    Rep Power
    15
    Try "return validate('<?php echo $name; ?>')"

  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2001
    Location
    Canada / NZ / UK
    Posts
    73
    Rep Power
    14
    Originally posted by Ulrik N
    <form name=form method="post" onsubmit="return validate(this)">

    you just have to use "this" in the ()'s
    he already said he tried this and it didnt work and wanted a way to put the variable in.

    and did my post turn invisible?
    Highest Leader of UM
  10. #6
  11. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2001
    Location
    Russia.
    Posts
    4
    Rep Power
    0
    To pass to your function the value of "name" textfield use the following: return validate(this.name.value)

IMN logo majestic logo threadwatch logo seochat tools logo