Results 1 to 6 of 6

Thread: generate order code

  1. #1
    Join Date
    Sep 2006
    Posts
    30
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default generate order code

    hello there...i really hope that someone can help me with this code...

    i have a drop down menu like this..
    <select name="d_type" class="enterinput" id="d_type">
    <option selected>Select Type</option>
    <option value="IMG" onClick="javascript">Image</option>
    <option value="STA">Statistic</option>
    <option value="DIR">Director</option>
    <option value="SHR">Share Holder</option>
    <option value="OTH">Other</option>
    <option value="OWR">Owner</option>
    <option value="COL">ROC Old Name</option>
    <option value="NME">ROC Name</option>
    </select>
    then...i need to generate the order code using the value from the drop down plus random number..such as.. IMG-1234567...

    the order code will be generated once the customer choose the "d_type" from the drop down menu...

    could anyone help me???

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Once submitted, just use:
    $final = $_POST['d_type'].rand(1000000,9999999);

    You can add javascript to the <select onChange...> to make it submit once an item it changed.

    You might also just want to use javascript if you need realtime.

    With PHP, that will need to be submitted.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    That looks like an order for disaster to me. The order codes must, unless they're just for show, be unique, which means storing a list of used order codes in a database and simply generating a code that's the lowest number that's not already taken.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  4. #4
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Agreed.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  5. #5
    Join Date
    Sep 2006
    Posts
    30
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by djr33 View Post
    Once submitted, just use:
    $final = $_POST['d_type'].rand(1000000,9999999);

    You can add javascript to the <select onChange...> to make it submit once an item it changed.

    You might also just want to use javascript if you need realtime.

    With PHP, that will need to be submitted.
    i need a realtime..so..could you show me the javascript??...i need to show the order code and at thesame time once the customer hit the "submit" button..the order code will be store into the database..

  6. #6
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    onChange="generate(this)"

    The function would be similar... something like:

    function generate(x) {
    x.value = x.value+random;
    }

    Not sure what random number functions exist for javascript. look that up.

    Javascript isn't really my thing.

    Also, I'd suggest what Twey is saying... makes a lot more sense. Just relying on client side scripting for order numbers is crazy... insecure, not compatible with everything AND duplicates could easily occur... etc.
    Using a database and secure server side coding is a much better option.
    php/mysql intro tutorial here:
    http://php-myql-tutorial.com
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •