Results 1 to 2 of 2

Thread: Setting the text value of a Server Control from a JavaScript variable

  1. #1

    Thread Starter
    Lively Member SpagettiProg's Avatar
    Join Date
    Dec 2004
    Location
    Miami, Florida
    Posts
    82

    Setting the text value of a Server Control from a JavaScript variable

    Hello,

    I have a webform which gets a text value from another form.
    It gets it via the following....

    Code:
    <SCRIPT language="JavaScript" type="text/javascript">
    	
    	function finish()
    			{
    			window.returnValue = 'Test It works';
    			window.close();	
    			}
    							
    		</SCRIPT>
    When I received the text value. See below.......

    Code:
    <script language="VBScript" type="text/vbscript">
    
    sub yeah()
    dim ret
    dim ofield
    	
    set ofield=Form1.elements("label3")		
    	
    ret = window.showModalDialog("clookup.aspx?" & ssearch ,"Lookup","dialogHeight:200px;dialogWidth:300px;status:no;")
    		
    ofield.text=ret
    'Here is where I try to assign the value of "Test it works"
    'to my asp label control
    
    end sub
    ret will have the text value of "Test it works", because I used document.write to output it, but I can't seem to add the value of ret to an aps.net label.

    lol, help, any ideas ?

    Thanks

  2. #2

    Thread Starter
    Lively Member SpagettiProg's Avatar
    Join Date
    Dec 2004
    Location
    Miami, Florida
    Posts
    82

    Re: Setting the text value of a Server Control from a JavaScript variable

    Disregard, as I figured it out.
    Apparently Labels do not like getting values.
    I tried the same thing with a textbox, and it worked just fine.

    Code:
    	sub clook() 
    
    	dim ret
    	dim ssearch 
    	dim oform
    	dim ofield
    		
    		set oform = document.forms("Form1")
    		set ofield = oform.elements("txtClientCode")
    		ret = null
    		ssearch = inputbox("Enter a client code or name:","Client Lookup")
    		if trim(ssearch) <> "" then
    			ret = window.showModalDialog("clookup.aspx?" & ssearch ,"Lookup","dialogHeight:200px;dialogWidth:300px;status:no;")
    		
    			'document.write(ret)
    			if ret <> "" then
    				ofield.value = ret
    			end if
    		end if
    end sub

Posting Permissions

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



Click Here to Expand Forum to Full Width