Forum Moderators: open

Message Too Old, No Replies

Error: Object Required

         

dereknw

2:28 pm on May 19, 2004 (gmt 0)

10+ Year Member



Hi all,

I have an error massage appearing on a page I have been working on and while it isn't breaking the page it's just plain annoying!

The message is:

Error: Object Required
Code: 0

The code in question is:

<script language="Javascript" type="text/javascript" "styleswitcher.js"></script>
<script language="Javascript" "text/javascript">function submitform(){document.myform.submit();}</script>

<form name="font_select" action="get">
<ul>
<li><a href="javascript: submitform()" onclick="javascript:fontsizeup()" title="Choose a font size that is most comfortable for you. Each click will increase the font size of this page (maximum four clicks)">Font+</a></li>
<li><a href="javascript: submitform()" onclick="javascript:fontsizedown();" title="Choose a font size that is most comfortable for you. Each click will decrease the font size of this page (maximum four clicks)">Font-</a></li>
</ul></form>

Anyone help?

Thanks in advance!

john_k

2:33 pm on May 19, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Your code is looking for a form named "myform", but your form is actually named "font_select".

dereknw

2:41 pm on May 19, 2004 (gmt 0)

10+ Year Member



Missed that one, thanks!

The error has gone but the form is being submitted to a blank page. Is there any way I can get the page to submit back to itself?

Not sure if i'm making myself clear!

Thanks

Bernard Marx

2:46 pm on May 19, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



dereknw, something curious there.

The link that calls

submitform
also calls
fontsizeup
.
What's happening?

--------------------

OK. In short. That depends what you mean :)
The page can reload itself. It all depends what your from is submitting to (cgi etc)

Perhaps you could outline what you like to happen generally speaking.

dereknw

3:18 pm on May 19, 2004 (gmt 0)

10+ Year Member



I have to apologise. Totally net to javascript and struggling to explain something I dont understand!

Ok here goes....there are 2 things i'm trying to do here.

The first is allow the user to change the font size of the page using a form to switch between alternative css pages:
<script language="Javascript" type="text/javascript" src="styleswitcher.js"></script>
onclick="javascript:fontsizeup()
onclick="javascript:fontsizedown();

The second thing (and this is where it falls over) is that I am trying to replace the notmal form buttongs with text links:
<script language="Javascript" type="text/javascript">function submitform(){document.self.submit();}</script>
<a href="javascript: submitform()">Font+</a>
<a href="javascript: submitform()"Font-</a>

I know..clear as mud! sorry

Bernard Marx

3:45 pm on May 19, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



No longer mud! Still a bit muddy though.

<script language="Javascript" type="text/javascript" src="styleswitcher.js"></script>
.......
<a href = "#" onclick="fontsizeup(); return false">Font+</a>
<a href = "#" onclick="fontsizedown();return false">Font-</a>

That's OK. I have filled in the elements, and altered a little
- no need for javascript: in onclicks
- return false , to stop the # being followed as a link (page jumps to top)

Now, this bit. You'll have to use separate elements for form submitting.
I'm assuming the form is unrelated to the font-size issue....

The big question is:
What does the form do?
Why does it have "Font+ ¦ -"

You don't need to submit a form to change fontsize.
I suspect that one of us has got the wrong end of the stick, and that could be either of us.

..........

..and perhaps it's me. A quick search reveals a PHP styleswitcher. Is that what's going on? I'll have to have a look.

[edited by: Bernard_Marx at 4:02 pm (utc) on May 19, 2004]

DrDoc

3:48 pm on May 19, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The error has gone but the form is being submitted to a blank page. Is there any way I can get the page to submit back to itself?

<form name="font_select" action="get">

That needs to be:

<form name="font_select" method="get" action="whateverthenameofthefileis.ext">

dereknw

8:36 am on May 20, 2004 (gmt 0)

10+ Year Member



I was just trying to change the font size on the page. I think my big mistake was trying to follow two tutorials at the same time, neither of which was exactly what i wanted. I seem ti have lost my way at some point:)

Anyway thanks all and especially Bernard Marx. it now works a treat!

Thanks all again