Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

object requried error

Status
Not open for further replies.

mravimtnl

MIS
Nov 1, 2009
47
I am getting an error of object required in the following code. Pls help me.


<head>
<meta http-equiv="Content-Language" content="en-us">
<script type="text/javascript">
function open_win()
{
try{
var x=parent.document.getElementById('1.Text1').nodeName;
var y=parent.document.getElementById('1.Text2').nodeName;
var mywin=window.open("");
mywin.document.write(x);
mywin.document.write(y);

}
catch(err)
{
txt="There was an error on this page.\n\n";
txt+="Error description: " + err.description + "\n\n";
txt+="Click OK to continue.\n\n";
alert(txt);
}
}
</script>
</head>
<body>
<form id="100"method="post" action="">
<input name="Text1" id="1" type="text">&nbsp;&nbsp;&nbsp;
<input name="Text2" id="2" type="text"><br>

&nbsp;<input type=button value="Open Window" onclick="open_win()" /></form>
</body>
 
Hi

You have no element with [tt]id[/tt] 1.Text1. Even if you would have, for long time that was invalid value for [tt]id[/tt], so in older browsers the behavior may be unexpected. So the below will work, but better use old fashioned [tt]id[/tt]s, starting with letter :
Code:
[b]var[/b] x[teal]=[/teal]parent[teal].[/teal]document[teal].[/teal][COLOR=darkgoldenrod]getElementById[/color][teal]([/teal][green][i]'1'[/i][/green][teal]).[/teal]nodeName[teal];[/teal]

Feherke.
 
Thanks for help. I have used. I am getting error undefinedundefined


<head>
<meta http-equiv="Content-Language" content="en-us">
<script type="text/javascript">
function open_win()
{
try{
var x=parent.document.getElementById('Text4').nodeName;
var y=parent.document.getElementById('Text5').nodeName;
var mywin=window.open("");
mywin.document.write(x.value);
mywin.document.write(y.value);

}
catch(err)
{
txt="There was an error on this page.\n\n";
txt+="Error description: " + err.description + "\n\n";
txt+="Click OK to continue.\n\n";
alert(txt);
}
}
</script>
</head>
<body>
<form id="100"method="post" action="">
<input name="Text1" id="Text4" type="text">&nbsp;&nbsp;&nbsp;
<input name="Text2" id="Text5" type="text"><br>

&nbsp;<input type=button value="Open Window" onclick="open_win()" /></form>
</body>
 
Hi

mravimtnl said:
I am getting error undefinedundefinedb
I suppose you get that in Trident. In Gecko, Presto and WebKit I get it correctly as "INPUTINPUT".

The only thing you can do is to use another property instead of [tt]nodeName[/tt], for example [tt]tagName[/tt] or maybe [tt]localName[/tt]. However I have no idea what you are trying to accomplish there.


Feherke.
 
I have share point list form. I want to grab the values from list and inset in popup for printing. For example, this is is the list form
______________________
Name > Text Box
Joined=Date Picker
Location= Dropdown.

button for printing
______________________

if a user clicks on button for printing, he should get message like this in the popup.
_____________________________________________________________
" Your Name is "Name from parent" . You joined at "Joined from parent" at location "location from parent".
_____________________________________________________________

The reason behind is sharepoint custom list doesnt give much leeway to add content and style them (printing of Input boxes are shabby as they leave white spaces when text is small and no print when text is big). I want to style the popup for printing

I cannot use asp here so javacscript.

 
I have tested in my desktop . It is functioning correctly. But it is not working in server. Any inputs. Pls also suggest me how can insert the variables in paragraph.

thanks in advance
 
Hi

I would do it like this :
Code:
[b]<form[/b] [maroon]action[/maroon][teal]=[/teal][green][i]"#"[/i][/green][b]>[/b]
[b]<input[/b] [maroon]name[/maroon][teal]=[/teal][green][i]"name"[/i][/green] [maroon]type[/maroon][teal]=[/teal][green][i]"text"[/i][/green][b]></label>[/b]
[b]<select[/b] [maroon]name[/maroon][teal]=[/teal][green][i]"location"[/i][/green][b]>[/b]
[b]<option[/b] [maroon]value[/maroon][teal]=[/teal][green][i]"Africa"[/i][/green][b]>[/b]Africa[b]</option>[/b]
[b]<option[/b] [maroon]value[/maroon][teal]=[/teal][green][i]"America"[/i][/green][b]>[/b]America[b]</option>[/b]
[b]<option[/b] [maroon]value[/maroon][teal]=[/teal][green][i]"Asia"[/i][/green][b]>[/b]Asia[b]</option>[/b]
[b]<option[/b] [maroon]value[/maroon][teal]=[/teal][green][i]"Australia"[/i][/green][b]>[/b]Australia[b]</option>[/b]
[b]<option[/b] [maroon]value[/maroon][teal]=[/teal][green][i]"Europe"[/i][/green][b]>[/b]Europe[b]</option>[/b]
[b]</select>[/b]
[b]<input[/b] [maroon]type[/maroon][teal]=[/teal][green][i]"button"[/i][/green] [maroon]value[/maroon][teal]=[/teal][green][i]"Printable format"[/i][/green] [maroon]onclick[/maroon][teal]=[/teal][green][i]"open_win(this.form)"[/i][/green][b]>[/b]
[b]</form>[/b]
JavaScript:
[b]function[/b] [COLOR=darkgoldenrod]open_win[/color][teal]([/teal]what[teal])[/teal]
[teal]{[/teal]
  [b]var[/b] mywin[teal]=[/teal]window[teal].[/teal][COLOR=darkgoldenrod]open[/color][teal]();[/teal]
  mywin[teal].[/teal]document[teal].[/teal][COLOR=darkgoldenrod]writeln[/color][teal]([/teal][green][i]'Your Name is '[/i][/green][teal]+[/teal]what[teal].[/teal]name[teal].[/teal]value[teal]+[/teal][green][i]'.'[/i][/green][teal]);[/teal]
  mywin[teal].[/teal]document[teal].[/teal][COLOR=darkgoldenrod]writeln[/color][teal]([/teal][green][i]'You joined at '[/i][/green][teal]+[/teal][b]new[/b] [COLOR=darkgoldenrod]Date[/color][teal]());[/teal]
  mywin[teal].[/teal]document[teal].[/teal][COLOR=darkgoldenrod]writeln[/color][teal]([/teal][green][i]' at location '[/i][/green][teal]+[/teal]what[teal].[/teal]location[teal].[/teal]value[teal]+[/teal][green][i]'.'[/i][/green][teal]);[/teal]
  mywin[teal].[/teal]document[teal].[/teal][COLOR=darkgoldenrod]close[/color][teal]();[/teal]
[teal]}[/teal]
Note that I used the current system time for join date. If you want a "manually" settable one, that would be similar to the name field.


Feherke.
 
Hi feherke (Programmer)

Thanks for your prompt responses.

My goal is to build form as given in this site.


I am wondering how the developer has developed such forms (Click create form and popu[ opnes with content and variable) as i am new to java script/js.

Any help/tutorials in this regard is highly solicited.

regads and thanx in advance.
 
Hi

[small][blue][tt][grumbling][/tt][/blue][/small]
I would not take that page as example. There is written :
rendered document said:
(Enter your children's names. Press after each child's name except the last one's)
Now what should be pressed ? People has to look in the source code to find out that the author failed to encode the less-than ( < ) and greater-than ( > ) signs :
HTML source said:
[tt]<font face="arial, sans-serif" size="1">(Enter your children's names. Press <enter> after each child's name except the last one's)</enter></font>[/tt]
And anyway, no idea what was in their mind, as pressing Enter simply submits the [tt]form[/tt].
[small][blue][tt][/grumbling][/tt][/blue][/small]
mravimtnl said:
I have share point list form.
Sorry, I have no idea what that share point is, and what actually you have when having such thing.

If you post some exact code I could try to adapt my previously posted code. Although it should not be hard to adapt it yourself.


Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top