Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 8th, 2005, 05:29 PM
Registered User
 
Join Date: Aug 2004
Location: kancheepuram, tamil nadu, India.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default can't read value from select tag using javascript

Hi to All,

           When i try to read value from the select tag ,show the "undefine error".

pls check any one and reply me...





<?php
echo "<html><title> welcome to php </title><body bgcolor='orange'>";
$design_table="<table border='1'> <tr> <td>xxx </td> <td> ddfff</td> </tr>
 </table>";

echo $design_table;
echo "<script language='javascript'>
           function ck()
               {
                  alert('welcome to php'+window.cname.value);
                 }
          function lis()
                      {

                          alert('Select item is:' + window.item.value);
                     }
          </script>";

echo "<input type=text name='cname' size=10>"."<br>"."<input type=password name='pwd'>

     <input type=button value='click me' onclick='ck()'>";

echo "<br> <select name='item'>
                    <option value='0' >Dosai
                    <option value='1' selected>Idle
        <option value='2'>Uthappam
       <option value='3'>Rice
      <option value='4'>Vadai
                 </select>";
echo "<input type=button value='check val' onclick='lis()'>";
echo "</body>"."</html>";
?>
Reply With Quote
  #2 (permalink)  
Old February 8th, 2005, 07:08 PM
Friend of Wrox
Points: 2,473, Level: 20
Points: 2,473, Level: 20 Points: 2,473, Level: 20 Points: 2,473, Level: 20
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2004
Location: India
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

You will not get value by window.item.value

you need to add document.form-name.item.value or use getelementbyid.

Om Prakash
Reply With Quote
  #3 (permalink)  
Old February 9th, 2005, 11:18 PM
Friend of Wrox
 
Join Date: Nov 2003
Location: , , .
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Put your form elements into a form and refer to the select element value by document.forms.YOUR_FORM_ID.item.options[document.forms.YOUR_FORM_ID.item.selectedIndex].value.

hth,

-Snib - http://www.snibworks.com
Where will you be in 100 years?
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to select only the parent tag and ignore the c Prem Rajesh Kumar XSLT 3 November 6th, 2007 12:53 PM
HTML tag from C# or ASP.NET tag from javascript angshujit ASP.NET 2.0 Basics 3 February 16th, 2007 10:07 AM
Quest: How to select the second tag?! gnesland XSLT 4 November 28th, 2006 11:09 AM
get displayed name of the <select> tag nikeshkm HTML Code Clinic 1 October 20th, 2006 11:21 PM
Dynamic Select Tag fs22 Javascript How-To 1 December 15th, 2004 08:32 PM



All times are GMT -4. The time now is 07:06 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.