Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Form will not submit! Non-Jscript programmer needs help.

Reply
Thread Tools

Form will not submit! Non-Jscript programmer needs help.

 
 
kheston1@centurytel.net
Guest
Posts: n/a
 
      09-19-2007
Hi,

I'm a ASP C# programmer who never uses javascript and had to try and
move a couple of functions (written by someone else) from one page to
another. The functions work fine, but when I copy them over they fail.
The last message was the the "frm" object did not support the "submit"
method. The function simply takes input from a text box and builds a
little form that it submits to a search site. These are the simplest
things but I can't figure it out - please help! Code is below.
Thanks!!

<script type="text/javascript">
function fnSearchWebstoreDL()
{
var frm = document.createElement("<head><META
name='WebPartPageExpansion'
content='full'></head><form name='frmSearchFormName'></form>");
frm.id = "frmSearchFormName";
frm.method = "GET";
frm.action = "http://webstore/webstoresupport/simplesearch.aspx";

var inpt = document.createElement("<input name='SearchFor'>");
inpt.id = "idSearchString";
inpt.value = document.all("txtSearchWebstoreDLFor").value;

frm.appendChild(inpt);
document.body.appendChild(frm);
frm.submit();
}

</script>

<body>
<table>
<tr>
<td>
<label>Webstore Support:</label>
<input id='Text1' type="text" name="txtSearchWebstoreDLFor"
size="25"
onkeypress="if(window.event.keyCode=='13')return(f nSearchWebstoreDL())"/
>

</td>
</tr>
</table>

</body>

 
Reply With Quote
 
 
 
 
Evertjan.
Guest
Posts: n/a
 
      09-19-2007
wrote on 19 sep 2007 in comp.lang.javascript:

> Hi,
>
> I'm a ASP C# programmer who never uses javascript and had to try and
> move a couple of functions (written by someone else) from one page to
> another. The functions work fine, but when I copy them over they fail.
> The last message was the the "frm" object did not support the "submit"
> method. The function simply takes input from a text box and builds a
> little form that it submits to a search site. These are the simplest
> things but I can't figure it out - please help! Code is below.
> Thanks!!
>
> <script type="text/javascript">
> function fnSearchWebstoreDL()
> {
> var frm = document.createElement("<head><META
> name='WebPartPageExpansion'
> content='full'></head><form name='frmSearchFormName'></form>");


document.createElement() only creates a tag element,
does not insert content, I think.

There probably is no reliable way to add a functioning <meta>,
after the page is loaded.


> frm.id = "frmSearchFormName";


This gives an id TO the created tag,
does not link to a form with a name,
even if it were created.

> frm.method = "GET";
> frm.action = "http://webstore/webstoresupport/simplesearch.aspx";
>
> var inpt = document.createElement("<input name='SearchFor'>");


Same nonsense

> inpt.id = "idSearchString";
> inpt.value = document.all("txtSearchWebstoreDLFor").value;


Ancient code,
use document.getElementById() or document.forms[].elements[]

>
> frm.appendChild(inpt);
> document.body.appendChild(frm);
> frm.submit();
>}
>
> </script>
>
> <body>


> <input id='Text1' type="text" name="txtSearchWebstoreDLFor"
> size="25"
> onkeypress="if(window.event.keyCode=='13')return(f nSearchWebstoreDL())"
> />


What a crap code, why the return?


why the />?
Is this ment to be IE only, btw?

Try, [not tested]:

=============================================
<input type='text' onkeypress = 'fnSearchWebstoreDL(this);'>

<script type='text/javascript'>
function fnSearchWebstoreDL(x) {
if (window.event.keyCode!=13) return;
var frm = document.createElement('Form');
// frm.id = 'frmSearchFormName'; // not used
// frm.method = 'GET'; // default
frm.action = 'http://webstore/webstoresupport/simplesearch.aspx';

var inpt = document.createElement('input');
inpt.name = 'SearchFor';
inpt.value = x.value;

frm.appendChild(inpt);
document.body.appendChild(frm);

frm.submit();
}
</script>
===============================================

or, [not tested]:

===============================================
<input type='text' onkeypress = 'fnSearchWebstoreDL(this);'>

<script type='text/javascript'>
function fnSearchWebstoreDL(x) {
if(window.event.keyCode!=13) return;
a = 'http://webstore/webstoresupport/simplesearch.aspx';
window.location.href = a + '?SearchFor=' + x.value;
}
</script>
===============================================

or just use a simple html form doing all this stuf,
[not tested]:

===============================================
<form action = "http://webstore/webstoresupport/simplesearch.aspx">
<input name ='SearchFor'>
</form>
===============================================


--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
 
Reply With Quote
 
 
 
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      09-19-2007
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> I'm a ASP C# programmer who never uses javascript


That is a quite ridiculous statement as C# requires ASP.NET which in turn
relies heavily on client-side JScript support by default.

> and had to try and move a couple of functions (written by someone else)
> from one page to another. The functions work fine, but when I copy them
> over they fail.


OMG.

> The last message was the the "frm" object did not support the "submit"
> method. The function simply takes input from a text box and builds a
> little form that it submits to a search site. These are the simplest
> things but I can't figure it out - please help!


Maybe you should let a Web developer do the job?

> Code is below. Thanks!!
> <script type="text/javascript">
> function fnSearchWebstoreDL()
> {
> var frm = document.createElement("<head><META
> name='WebPartPageExpansion'
> content='full'></head><form name='frmSearchFormName'></form>");


Although your code is not Valid (see http://validator.w3.org/),
this is not a J(ava)Script problem. Get informed about the DOM.

http://www.w3.org/TR/DOM-Level-3-Cor...#ID-2141741547
http://msdn2.microsoft.com/en-us/library/ms536389.aspx


PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
 
Reply With Quote
 
kheston1@centurytel.net
Guest
Posts: n/a
 
      09-19-2007
Hey Evertjan - thanks a million for the help! I'll try your
suggestions immediately.

Thomas - couldn't agree with you more. I'm a hell of a lame
programmer. Also, you make a very good point about DOM. I do need to
get more up to speed on that contruct. Thanks for your feedback!

Keith


On Sep 19, 4:28 am, Thomas 'PointedEars' Lahn <(E-Mail Removed)>
wrote:
> (E-Mail Removed) wrote:
> > I'm a ASP C# programmer who never uses javascript

>
> That is a quite ridiculous statement as C# requires ASP.NET which in turn
> relies heavily on client-side JScript support by default.
>
> > and had to try and move a couple of functions (written by someone else)
> > from one page to another. The functions work fine, but when I copy them
> > over they fail.

>
> OMG.
>
> > The last message was the the "frm" object did not support the "submit"
> > method. The function simply takes input from a text box and builds a
> > little form that it submits to a search site. These are the simplest
> > things but I can't figure it out - please help!

>
> Maybe you should let a Web developer do the job?
>
> > Code is below. Thanks!!
> > <script type="text/javascript">
> > function fnSearchWebstoreDL()
> > {
> > var frm = document.createElement("<head><META
> > name='WebPartPageExpansion'
> > content='full'></head><form name='frmSearchFormName'></form>");

>
> Although your code is not Valid (seehttp://validator.w3.org/),
> this is not a J(ava)Script problem. Get informed about the DOM.
>
> http://www.w3.org/TR/DOM-Level-3-Cor.../ms536389.aspx
>
> PointedEars
> --
> realism: HTML 4.01 Strict
> evangelism: XHTML 1.0 Strict
> madness: XHTML 1.1 as application/xhtml+xml
> -- Bjoern Hoehrmann



 
Reply With Quote
 
 
 
Reply

Thread Tools

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
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Urgent positions: Sr Programmer Analyst (SPA) and Programmer Analyst(PRA)-06+month's- Carson City, NV. Isaac Java 0 12-08-2010 06:32 PM
Urgent positions: Sr Programmer Analyst (SPA) and Programmer Analyst(PRA)-06+month's- Carson City, NV. Isaac Java 0 12-08-2010 05:34 PM
Who gets higher salary a Java Programmer or a C++ Programmer? Sanny Java 391 01-06-2010 02:48 AM
Who gets higher salary a Java Programmer or a C++ Programmer? Sanny C++ 396 12-17-2008 06:13 PM
Non Java programmer needs help!! John Grogan Java 2 10-02-2003 09:13 AM



Advertisments