Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Mar 13th, 2007, 2:02 PM   #1
anant_tickoo
Programmer
 
Join Date: Sep 2005
Posts: 50
Rep Power: 0 anant_tickoo is an unknown quantity at this point
Exclamation unable to get values using DOM

below is the conde of my site wot im trying to make.

the problem is the i am not able to access the value of data entered in
<input></input>


document.getElementById('ty4').innerHTML=document.getElementById('ticket').value;

this line retunrs undefined ..

can any one help me out

<html>
<head>
<meta http-equiv="refresh" content="2222"/>
</meta>
</head>
<script = "javascript"> 

function disp()
{
	var s_sev=document.getElementById('sev').value;
	var s_Outage=document.getElementById('Outage').value;
	var s_ticket=document.getElementById('ticket').value;
	var s_area=document.getElementById('area').value;
	var s_area=document.getElementById('status').value;
	var s_area=document.getElementById('Transfer').value;
	var s_area=document.getElementById('Problem').value;
	var s_area=document.getElementById('AHT').value;
	var s_area=document.getElementById('noti').value;
	
	switch(s_sev)
	{
		case 'sev 4':
		document.getElementById('ts1').style.backgroundColor='#FFC1FF';
		break;
		case 'sev 3':
		document.getElementById('ts1').style.backgroundColor='#CFD8F4';
		break;
		case 'sev 2':
		document.getElementById('ts1').style.backgroundColor='#1FD6F8';
		break;
		case 'sev 1':
		document.getElementById('ts1').style.backgroundColor='#FF3300';
		break;
		case 'sev 0':
		document.getElementById('ts1').style.backgroundColor="white";
		break;
	}
		
	if(s_Outage=='Planed')
		document.getElementById('ty2').innerHTML='PLANED';
	else
		document.getElementById('ty2').innerHTML='UNPLANED';

			document.getElementById('ty1').innerHTML=document.getElementById('sev').value; 
			document.getElementById('ty4').innerHTML=document.getElementById('ticket').value; 
			document.getElementById('ty6').innerHTML=document.getElementById('Problem').value; 
			document.getElementById('ty7').innerHTML=document.getElementById('status').value; 
			document.getElementById('ty8').innerHTML=document.getElementById('noti').value; 
			

			
}
</script>




<body bgcolor="#AFD6F8">

<fieldset>
<legend>
STATUS TOOL:
</legend>
<TABLE align="center">
<FORM name="ticket" >
<tr><td>
<p align="center">SEV<br>
<select id="sev">
<option selected value="sev 4">sev 4</option> 
<option value="sev 3">sev 3</option> 
<option value="sev 2">sev 2</option> 
<option value="sev 1">sev 1</option> 
<option value="sev 0">sev 0</option>
</select>
</td>
&nbsp &nbsp &nbsp
<td>
Outage Type<br>
<select ID="Outage">
<option value="Unplaned" selected>Unplaned</option> 
<option value="Planed">Planed</option> 
</select>
</td>
&nbsp &nbsp &nbsp

<td>
<p align="center">Ticket No <br>
<input size="15" value="TICKET" onclick="this.value=''" name="ticket" rows="1" cols="20"></input></td>
&nbsp &nbsp &nbsp

<td>
<p align="center">Area under effect<br>
<input size="20" id="area"></input></td>
&nbsp &nbsp &nbsp
<td>
<p align="center">Problem Description <br><textarea rows="2" cols="20" id="Problem"></textarea></td>
&nbsp &nbsp &nbsp
<td>Status<br><select ID="status">
<option value="Transfered" selected>Transfered</option> 
<option value="Resolved">Resolved</option> 
<option value="Closed">Closed</option> 
<option value="SLAHOLD">SLAHOLD</option> 
</select>
</td>
<td>
Transferred Q<br>
<input size="10" ID="Transfer"></input>
</td>
<td>
<p align="center">AHT<br>
<input size="10" id="AHT"></input>
</td>
<td>
<p align="center">Notification
<select id="noti">
<option selected value="NO">NO</option>
<option value="YES">YES</option>
</select>
</td>

<tr>
<td>
<p align="center">
<input  type="button"  value="Submit" size="20" onclick=disp()></td><td>
<p align="center"><input type="reset" value="Reset" name="B2"></td>
</tr>

</tr>
</Form>
</TABLE>
</fieldset>
<p dir="ltr">&nbsp;</p>

<table border="1" cellspacing="1" style="border-collapse: collapse" bordercolor="#FFFFFF" width="100%" >
  <tr id="ts1">
    <td id="ty" width="8%" ></td>
    <td id="ty1" width="9%"></td>
    <td id="ty2" width="11%"></td>
    <td id="ty3" width="11%"></td>
    <td id="ty4" width="11%"></td>
    <td id="ty5" width="11%"></td>
    <td id="ty6" width="15%"></td>
    <td id="ty7" width="11%"></td>
    <td id="ty8" width="12%"></td>
  </tr>
</table>

</body>
</html>
anant_tickoo is offline   Reply With Quote
Old Mar 13th, 2007, 2:57 PM   #2
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Perhaps it's because there's not a element with id="ticket".
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Mar 13th, 2007, 3:35 PM   #3
anant_tickoo
Programmer
 
Join Date: Sep 2005
Posts: 50
Rep Power: 0 anant_tickoo is an unknown quantity at this point
according to the the below its is an element....

http://msdn.microsoft.com/library/de...e/elements.asp
anant_tickoo is offline   Reply With Quote
Old Mar 13th, 2007, 3:49 PM   #4
anant_tickoo
Programmer
 
Join Date: Sep 2005
Posts: 50
Rep Power: 0 anant_tickoo is an unknown quantity at this point
now this is working fine .. why...
kindly explain

<html>
<head>
<meta http-equiv="refresh" content="2222"/>
</meta>
</head>
<script = "javascript"> 

function disp()
{
	var s_sev=document.getElementById('sev').value;
	var s_Outage=document.getElementById('Outage').value;
	var s_ticket=document.getElementById('ticket').value;
	var s_area=document.getElementById('area').value;
	var s_area=document.getElementById('status').value;
	var s_area=document.getElementById('Transfer').value;
	var s_area=document.getElementById('Problem').value;
	var s_area=document.getElementById('AHT').value;
	var s_area=document.getElementById('noti').value;
	
	switch(s_sev)
	{
		case 'sev 4':
		document.getElementById('ts1').style.backgroundColor='#FFC1FF';
		break;
		case 'sev 3':
		document.getElementById('ts1').style.backgroundColor='#CFD8F4';
		break;
		case 'sev 2':
		document.getElementById('ts1').style.backgroundColor='#1FD6F8';
		break;
		case 'sev 1':
		document.getElementById('ts1').style.backgroundColor='#FF3300';
		break;
		case 'sev 0':
		document.getElementById('ts1').style.backgroundColor="white";
		break;
	}
		
	if(s_Outage=='Planed')
		document.getElementById('ty1').innerHTML='PLANED';
	else
		document.getElementById('ty1').innerHTML='UNPLANED';

			document.getElementById('ty').innerHTML=document.getElementById('sev').value; 
			document.getElementById('ty2').innerHTML=document.getElementById('area0').value; 
			document.getElementById('ty4').innerHTML=document.getElementById('Problem').value; 
			document.getElementById('ty5').innerHTML=document.getElementById('status').value; 
			document.getElementById('ty8').innerHTML=document.getElementById('noti').value; 
			document.getElementById('ty7').innerHTML=document.getElementById('AHT').value; 
			document.getElementById('ty3').innerHTML=document.getElementById('area').value; 

			
}
</script>




<body bgcolor="#AFD6F8">

<fieldset>
<legend>
STATUS TOOL:
</legend>
<TABLE align="center">
<FORM name="ticket" >
<tr><td>
<p align="center">SEV<br>
<select id="sev">
<option selected value="sev 4">sev 4</option> 
<option value="sev 3">sev 3</option> 
<option value="sev 2">sev 2</option> 
<option value="sev 1">sev 1</option> 
<option value="sev 0">sev 0</option>
</select>
</td>
&nbsp &nbsp &nbsp
<td>
Outage Type<br>
<select ID="Outage">
<option value="Unplaned" selected>Unplaned</option> 
<option value="Planed">Planed</option> 
</select>
</td>
&nbsp &nbsp &nbsp

<td>
<a align="center">Ticket No<br>
</input>
</a>
<input size="13" type=text id="area0" name="1"><a align="center">
</a></td>

<td>
<p align="center">Area under effect<br>
<input size="20" type=text id="area"></input></td>
&nbsp &nbsp &nbsp
<td>
<p align="center">Problem Description <br><textarea rows="2" cols="20" id="Problem"></textarea></td>
&nbsp &nbsp &nbsp
<td>Status<br><select ID="status">
<option value="Transfered" selected>Transfered</option> 
<option value="Resolved">Resolved</option> 
<option value="Closed">Closed</option> 
<option value="SLAHOLD">SLAHOLD</option> 
</select>
</td>
<td>
Transferred Q<br>
<input size="10" ID="Transfer"></input>
</td>
<td>
<p align="center">AHT<br>
<input size="10" type=text id="AHT"></input>
</td>
<td>
<p align="center">Notification
<select id="noti">
<option selected value="NO">NO</option>
<option value="YES">YES</option>
</select>
</td>

<tr>
<td>
<p align="center">
<input  type="button"  value="Submit" size="20" onclick=disp()></td><td>
<p align="center"><input type="reset" value="Reset" name="B2"></td>
</tr>

</tr>
</Form>
</TABLE>
</fieldset>
<p dir="ltr">&nbsp;</p>

<table border="3" cellspacing="1" style="border-collapse: collapse" bordercolor="#00CCFF" width="100%" >
  <tr id="ts1">
    <td id="ty" width="8%" ></td>
    <td id="ty1" width="9%"></td>
    <td id="ty2" width="11%"></td>
    <td id="ty3" width="11%"></td>
    <td id="ty4" width="15%"></td>
    <td id="ty5" width="11%"></td>
    <td id="ty6" width="11%"></td>
    <td id="ty7" width="11%"></td>
    <td id="ty8" width="12%"></td>
  </tr>
</table>

</body>
</html>
anant_tickoo is offline   Reply With Quote
Old Mar 13th, 2007, 3:53 PM   #5
kruptof
Professional Programmer
 
kruptof's Avatar
 
Join Date: May 2006
Location: UK - London
Posts: 329
Rep Power: 3 kruptof is on a distinguished road
Quote:
Originally Posted by anant_tickoo View Post
according to the the below its is an element....

http://msdn.microsoft.com/library/de...e/elements.asp
I check that site and i can't seem to see this ticket element.
__________________
Quote:
When I was young it seemed that life was so wonderful,a miracle, oh it was beautiful, magical.
Now watch what you say or they'll be calling you a radical,a liberal, oh fanatical, criminal. Oh won't you sign up your name,we'd like to feel you're acceptable, respectable, oh presentable, a vegetable
kruptof is offline   Reply With Quote
Old Mar 13th, 2007, 4:06 PM   #6
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5 Arevos is on a distinguished road
document.getElementById does what it says on the tin. It gets elements by their "id" attribute. Your form has a name, but not an id:
<FORM name="ticket" >
Now, certain browsers (*cough*Microsoft Internet Explorer*cough*) implement getElementById to search for name attributes as well as ids in order to support broken legacy behaviour. However, it's not a habit you should get into. Maybe the problem you're facing is because you tested it in a browser other than IE (does IE7 still support this broken behaviour?), and then later on in IE.
Arevos is offline   Reply With Quote
Old Mar 13th, 2007, 4:08 PM   #7
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Did you read the response? In your first example, there is this block of statements (note the bold):
document.getElementById('ty1').innerHTML=document.getElementById('sev').value; 
document.getElementById('ty4').innerHTML=document.getElementById('ticket').value; 
document.getElementById('ty6').innerHTML=document.getElementById('Problem').value; 
document.getElementById('ty7').innerHTML=document.getElementById('status').value; 
document.getElementById('ty8').innerHTML=document.getElementById('noti').value;
There is no element in the code with id="ticket", so that statement won't work. In the second example, you got rid of that statement. You are still trying it in other statements. Either give an element the "ticket" id, or quit trying to fetch it with getElementById.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Mar 13th, 2007, 4:14 PM   #8
anant_tickoo
Programmer
 
Join Date: Sep 2005
Posts: 50
Rep Power: 0 anant_tickoo is an unknown quantity at this point
thanks guys veys much ..
i did it ..

thanks very much
anant_tickoo is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
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 On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
queries page, recieves values... Komodo JavaScript and Client-Side Browser Scripting 3 Dec 17th, 2006 11:25 AM
dealing cards brad sue C 21 Mar 28th, 2006 1:21 AM
Passing 'enumeration' values Kilo C# 4 Dec 15th, 2005 1:31 PM
Returning two values Navid C 19 Jun 13th, 2005 2:57 AM
Problem Inserting Values into mySQL from PHP stakeknife PHP 1 Mar 23rd, 2005 8:45 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 12:20 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC