Server Side Scripter needs help on Client Side 
Author Message
 Server Side Scripter needs help on Client Side

I have been working on an ASP page that stores information into a
database.  As part of the process I want a client side script that runs
at submit_onclick() that creates an Outlook message to send mail.  The
script works but I am having problems with getting the value of
<SELECT></SELECT> form controls.  On the server side
Request.Form("SelectName") does return the correct value.  I tried using
document.formname.selectname.value on the client script, but it only
returns blank strings.  This same syntax works for text boxes, and text
areas.

This is obviously something I am doing wrong, but I can't figure out
what.  I didn't want to redesign the page using the Visual InterDev
design time controls if I can help it.  Can someone give me some
insight??  I did not attach specific code, because the example I listed
is close enough to answer my question.



Sat, 05 May 2001 03:00:00 GMT  
 Server Side Scripter needs help on Client Side

You can't just grab the value of the select box.

Instead, you have to get the value of the currently selected option.

document.formName.selectName.options[document.formName.selectName.selectedIndex].value

------------------------
John T. Spivey

  I have been working on an ASP page that stores information into a
  database.  As part of the process I want a client side script that runs
  at submit_onclick() that creates an Outlook message to send mail.  The
  script works but I am having problems with getting the value of
  <SELECT></SELECT> form controls.  On the server side
  Request.Form("SelectName") does return the correct value.  I tried using
  document.formname.selectname.value on the client script, but it only
  returns blank strings.  This same syntax works for text boxes, and text
  areas.

  This is obviously something I am doing wrong, but I can't figure out
  what.  I didn't want to redesign the page using the Visual InterDev
  design time controls if I can help it.  Can someone give me some
  insight??  I did not attach specific code, because the example I listed
  is close enough to answer my question.



Sat, 05 May 2001 03:00:00 GMT  
 Server Side Scripter needs help on Client Side
An interesting solution, but I found one that was easier to read.  If I
set the VALUE= in the <OPTION> tag to be what was displayed in the list
box, then yes I could just grab the value as I had described.  I am not
sure if that was the best way to do it, but it worked.  I only had to
modify the code slightly to get the ASP to regenerate the listbox, and
then the client side script processed it just fine.

I appreciate your answer. I created a mock form in Visual InterDev using
the listbox DTC and saw that it created the listbox with <OPTION
VALUE="somevalue">somevalue as each of the drop down options.  I took
this to mean that I would need the same in my listbox (which I generated
by hand) and when I added it, voila!!

Quote:

>   You can't just grab the value of the select box. Instead, you have
> to get the value of the currently selected
> option. document.formName.selectName.options[document.formName.selectName.selectedIndex].value

> ------------------------
> John T. Spivey



Mon, 07 May 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Help converting server-side VBScript array into client-side JScript array

2. attached Contact Item on server-side becomes attached Mail Item on client-side

3. How Can I Pass Data Between the Server Side and the Client Side VB/JScript

4. Server side or client side cursors?

5. Printing report at the client side and the report is at the server side

6. Printing report at the client side and the report is at the server side

7. Mixing of client-side and server-side scripts

8. Server side variables to client side script?

9. Server-Side vs Client-Side script

10. Using Server side Vs OnClick Client side

11. Client Side + Server Side Scripts

12. Passing a server side var to client side block

 

 
Powered by phpBB® Forum Software