www.webdeveloper.com
Results 1 to 5 of 5

Thread: problem in passing java script variable to asp page

  1. #1
    Join Date
    Dec 2005
    Posts
    2

    problem in passing java script variable to asp page

    Hi,

    My asp page has a dropdown box .When a value is selected in that,it calls a javascript function in which i have to catch the value of that selecteditem of dropdown box.This value should be passed to asp page so that a query is run with that and a textbox is populated with the result of that query.following is the code for that.

    When i use the following code thre are many problems with that.For the first time when i select something from the dropdown box, nothing is getting displyed and from the second time,data is being displayed in the textbox....but
    immediately the web page is getting reloaded again and all the data is lost.

    Please help me in this....
    <%@ LANGUAGE="VBSCRIPT" %>
    sub showform
    </SCRIPT>
    <TITLE>SVR StartDate Selection</TITLE>
    </HEAD>
    <BODY >
    <FORM method=post name=f1 ID="Form1">
    function OOchange()
    {
    var Campus="";
    if(document.f1.Campus.options[document.f1.Campus.selectedIndex].value)
    {
    Campus=document.f1.Campus.options[document.f1.Campus.selectedIndex].value;

    window.location = 'svr_temp.asp?Campus=' + Campus;
    hidden_Team_Auto.style.display='block';
    }

    }
    </script>

    <!--#include File="../inc/LSDevConn.asp"-->
    <%
    if request.querystring("Campus") <> "" then
    'response.Write("hi")
    'response.End
    MYSQL2="Select distinct substring(collector_name,13,5) AS Code from svr_compare where substring(collector_name,1,4)= (select Collector_Code from CampCollCode where Division='"& request.QueryString("Campus")& "')"
    Set MyRs2=MyConn.Execute(MySQL2)
    Dim str
    str=MyRS2("Code")
    MyRS2.MoveNext
    Do While NOT MyRS2.EOF
    str=str & "," & MyRS2("Code")
    MyRS2.MoveNext
    loop
    end if
    %>
    <TR id="hidden_Team_Auto" style="display:none;">
    <TD align=left height="48">
    <INPUT type=text name=TeamNumAuto maxlength=25 size=15 value= "<% =str %>" ID="Text1">
    </TD>
    </TR>

  2. #2
    Join Date
    Dec 2003
    Location
    England, UK
    Posts
    432
    did you mean to post more than just this bit of code?

  3. #3
    Join Date
    Dec 2005
    Posts
    2
    i am sorry i didn't get u.....what's your question?

  4. #4
    Ubik's Avatar
    Ubik is offline &lt;%= &quot;New Meja Hor&quot; %&gt;
    Join Date
    Nov 2005
    Location
    Earth
    Posts
    361
    The javascript you are running is client-side and the asp is server-side.

    Also, you haven't exactly explained what you are trying to do, and the form code (select, option html tags) are missing from your request, so we can't tell what you are doing.

    Perhaps you can use AJAX or something?

  5. #5
    Join Date
    Dec 2005
    Posts
    155
    code u have posted doesn't allow us to help u

    i think it is copying error, because there are errors in the code (the page won't run with these errors) for example: the script tags are out of place etc

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles