creating a form using Javascript

F

Frederik S

Hello,

I'm making a nice little login box in Javascript but having problems Posting
the value inside a textfield.
In a nutshell:

I have a function:

function getPostData (value)

Which correctly gets the value, but how do I then create a form and submits
inside Javascript?

Help much appreciated,

Frederik Sunne
 
E

Evertjan.

Frederik S wrote on 15 nov 2003 in comp.lang.javascript:
I'm making a nice little login box in Javascript but having problems
Posting the value inside a textfield.
In a nutshell:

I have a function:

function getPostData (value)

Which correctly gets the value, but how do I then create a form and
submits inside Javascript?

A form is HTML, so you cannot make a form inside javascript.
What you can do is have javascript make the HTML for you.
What you can do is javascript submit the HTML form
with a onclick="submit()".

It is very unclear what getPostData() does if you do not show the function
script and what "value" should contain.

Please show us and explain what you want to do.
 
C

Charlene Russ

Mr. Evertjan is right, Forms are created by using HTML tags. You may
however define functions that relate to the form withing JavaScript tags.
Inside the script tags are where you declare your javascript variables,
assign objects and declare functions. Using Event handlers withing the HTML
form such as onClick you may call your functions.

An example might be:

<form name="myform">

<input type="button" name="Button1" value="Vector 1"
onClick="swap1();">
<input type="button" name="Button2" value="Vector 2"
onClick="swap2();">
<input type="button" name="Button3" value="Vector 3"
onClick="swap3();" >
<input type="button" name="Button4" value="Vector 4"
onClick="swap4();" >
</form>

Good luck,

-Charlene
Intro. JavaScript
http://www.eclecticacademy.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top