retrieve selected value

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • VanZandt
    New Member
    • Oct 2006
    • 5

    retrieve selected value

    how do I get a cell value for selected qty? Please help!!!
    below is the code.

    Thanks,

    Code:
    <?xml version = "1.0" encoding = "utf-8"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
     
    <html xmlns = "http://www.w3.org/1999/xhtml">
     
     
       <head>
    	<title>Incredible Roadside Assistance&reg; - Products</title>	
     
    	<object id = "Product"
    		classid = "CLSID:333C7BC4-460F-11D0-BC04-0080C7055A83">
    		<!--supply file location and name-->
    		<param name = "DataURL" value = "Products.txt" />
    		<!--specify whether first row is a header-->
    		<param name = "UseHeader" value = "TRUE" />
    		<!--denote the data field start and end -->
    		<param name = "TextQualifier" value = "*" />
    		<!--denote the field delimiter-->
    		<param name = "FieldDelim" value = "|" />
    	</object>
    	
    	<script type = "text/javascript">
     
    	function submitForm( )
    	{	
    	   alert("submit");
               
    	   var fileSysObj = new ActiveXObject("Scripting.FileSystemObject") ;
    	   var textFile = fileSysObj.CreateTextFile("Order.txt", true) ;
    	   var qty="";
           alert( getText(document.getElementById("qty")) );       
    	   textFile.WriteLine("total") ;
    	   textFile.Close( ) ;	   
    	   window.alert("A file has been created.") ;
    	
    
    	}
     
        function getText(el)
        {
            if (el.textContent) return el.textContent;
            if (el.innerText) return el.innerText;
            return el.innerHTML.replace(/<[^>]*>/g,'');
        }
    
    
    	function resetForm( )
    	{
    	//set event's return value to false to override its default behavior
    	window.event.returnValue = false ;
    	//display a msgbox with OK and Cancel buttons on it
    	if (confirm("Are you sure you want to clear the form?"))
    	   {
    		//let the default behavior occur
    		window.event.returnValue = true ;
    	   }
    	else
    	   {
    		//do nothing
    	   }
    	}
     
    	function createFile( )
    	{
    	   	   
    	}
     
    	//]]>
    	</script>
    
       </head>
       
       <body style = "background-color: bisque">
       <form id="form1" onsubmit= "submitForm( )" onreset="resetForm( )" action=" ">
    	<h1 style = "text-align:center">Incredible Roadside Assistance&reg; - Product Information</h1>
    	<div style = "text-align: center">
    	   <select onchange = "Product.Sort = this.value; Product.Reset( ); ">
    	    <!--sort by Product ID data field in ascending order-->
    		<option value = "ProdID">Product ID - Ascending</option>
    		<!--sort by Product ID data field in descending order-->
    		<option value = "-ProdID">Product ID - Descending</option>
    		<!--sort by Product Name data field in ascending order-->
    		<option value = "ProdName" selected>Product Name - Ascending</option>
    		<!--sort by Product Name data field in descending order-->
    		<option value = "-ProdName">Product Name - Descending</option>
    		<!--sort by Product Desc data field in ascending order-->
    		<option value = "ProdDesc">Product Description - Ascending</option>
    		<!--sort by Product Desc data field in descending order-->
    		<option value = "-ProdDesc">Product Description - Descending</option>
    	   </select>
    	</div>
    	<p>
    	<span style = "background-color: bisque; position: absolute;
    	   margin-left: 15%; width: 67%; border-style: ridge; text-align: center;
    	   padding: 1em">
    	   <table id="myTable" datasrc = "#Product" >
    		<thead>
    		   <tr>
    		    <th>Product ID</th>
    			<th>Product Name</th>
    			<th>Description</th>
    			<th>&nbsp;</th>
    			<th>Qty</th>
    			<th></th>
    		   </tr>
    		</thead>
    		<tbody>
    		   <tr>
    		      <td>
    			    <span datafld = "ProdID">Product ID goes here.</span>
    		      </td>
    		      <td>
    			    <span datafld = "ProdName">Name goes here.</span>
    		      </td>
    		      <td>		      
    			    <span datafld = "ProdDesc">Description goes here.</span>
    		      </td>
    		      <td>
    			    <span>
    			       <img datafld = "Image" alt="Image goes here."></img>
    			    </span>
    		      </td>
    		      <td>
    			<span>
    			<select ID="qty" Name="qty" onchange = "Product.Sort = this.value; ">
    		            <option value = "0">0</option>
    		            <option value = "1">1</option>
    		            <option value = "2">2</option>
    		            <option value = "3">3</option>
    		            <option value = "4">4</option>
    		            <option value = "5">5</option>
    		            <option value = "6">6</option>
    		            <option value = "7">7</option>
    		            <option value = "8">8</option>
    		            <option value = "9">9</option>
    		            <option value = "10">10</option>
    	               	</select>
    			    </span>
    		      </td>
    		   </tr>
    		</tbody>
    	   </table>
    	   <table>
            <tr>
    		    <td>
    		        <input type="submit" id="btnSubmit" value="Submit" />
    		        &nbsp;&nbsp;
    		        <input type="reset" id="btnCancel" value="Cancel" />
    		    </td>
    		</tr>
    	   </table>
     	</span>
    	</p>
    	</form>
       </body>
    </html>
    Last edited by Dormilich; Apr 27 '10, 06:50 AM. Reason: Please use [code] tags when posting code
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    form controls always have the .value attribute/property, holding their, er, value.

    PS. that code only works in IE (just to have it mentioned)

    Comment

    Working...