Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    May 2003
    Location
    Columbia, SC
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    PLEASE HELP..VBSCRIPT/ASP/Javascript

    Hi,

    I am developing a webpage and I need to write some VBscripts or Javascript function so that I can call this function when I select a customer number from a available drop-down list of customers. I mean at "Onchange" event. As soon as I select/change the customer number it should have to refresh the name & address details for that customer number. All the information (address, name etc.) need to be selected from database. I tried to write VBscript function using <Script> tagg but the problem is that I am unable to write a code in order to access the database. If i write the same logic/code in Vbscript with <% %> tags it doesn't recongnize the function call <%function_name()%> on "Onchange" event. Please Help me and let me know which kind of VBscript (tags) will be used. Is there anything I can write in Javascript in order to access the database?
    Any Help is highly Appreciated.

    Thanks.
    Pktyagi

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    See point 1 here.


    Don't make the mistake of thinking you can run server side script or function in response to end user actions on the same page. You have to post to the server and get a whole page in response.
    Last edited by Roy Sinclair; 06-03-2003 at 05:10 PM.
    Check out the Forum Search. It's the short path to getting great results from this forum.

  • #3
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    i think u may have 2 possibilities:

    1. use php or asp or whichever to generate your whole page from database.

    Inside your page, there will be generate some javascript variables, say var address1 = "text address1 here", var address2 ="text address2 here" and so on.

    Build an input text and give it a name. build a javascript function which writes those variables onto that input text. Onchange direct to that function, according to the selected Index.

    <html>
    <head>
    <title></title>
    <script language="JavaScript">
    function change(){
    var address1 = "text address1 here";
    var address2 ="text address2 here";

    var selval = document.forms[0].selectname.selectedIndex;
    if(selval == 1){
    document.forms[0].textfield.value = address1;
    }
    if(selval == 2){
    document.forms[0].textfield.value = address2;
    }
    }
    </script>
    </head>
    <body bgcolor="#FFFFFF" text="#000000">
    <form>
    <select name="selectname" size="1" OnChange="change()">
    <option selected>Choose name</option>
    <option>name1</option>
    <option>name2</option>
    </select><br>
    <br>
    <br>
    <br>
    <input type="text" name="textfield" size="40">
    </form>
    </body>
    </html>


    Well, if there are a lot of data in the data base, you can optyimize the script using an array and/or a "for/to" cicle within the if sentences.

    2. put the address in an iframe. Build a submit button near the select tag, in the same form, this time with a POST method to a CGI aplication who will build that iframe using data base.

    That is what I can think it might work. We use something similar(the first ideea) in our page at http://www.amaltea.ro/comanda.php
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #4
    Regular Coder
    Join Date
    Jul 2002
    Posts
    698
    Thanks
    0
    Thanked 0 Times in 0 Posts
    and then there is the 3rd option. this is only to give u an idea

    where u make a asp file that selects the customer data for one custormer in ur db by customernumber.:

    thisCustomer.asp
    this file end output should look something like this
    document.forms[0].textfield.value = address2;


    and u have your main fil

    Customers.asp

    <html>
    <head>
    <script src="" id="loader"></script>
    <script language="JavaScript">
    function change(){
    var customerNr = document.forms[0].selectname.selectedIndex;

    document.all.loader.src="thisCustomer.asp?CustomerNr="+customerNr;

    }
    }
    </script>
    </head>
    <body bgcolor="#FFFFFF" text="#000000">
    <form>
    <select name="selectname" size="1" OnChange="change()">
    <option selected>Choose name</option>
    <option>name1</option>
    <option>name2</option>
    </select><br>
    <br>
    <br>
    <br>
    <input type="text" name="textfield" size="40">
    </form>
    </body>
    </html>


  •  

    Posting Permissions

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