CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Other Programming Languages: Javascript:
Capturing value entered in textfield of form and using in javascript code

 



saturn
New User

Jun 2, 2009, 2:57 AM

Post #1 of 2 (21465 views)
Capturing value entered in textfield of form and using in javascript code Can't Post

Hello!

I am just a beginnerin javascript,so pls need your help!

I am making a website using html.I need to capture a value from a textfield of one form in a page and use the value in an if-else loop in javascript in another page.How to capture the value that would be given by any user and use the value to run the loop to display certain information to the user according to the value? And where should I put the script in the head section or the body section?

I have made the form as-

<form action="tariff2.html">
<center><b>Connected load:
<input type="text" name="load" size="30"></b></center>
<center><br><br><br>
<input type="submit" name="Submit" value=" Submit "
onKeyPress="return submitenter(this,event)"> &nbsp;&nbsp;&nbsp;&nbsp;
<input type="reset" name="Reset" value=" Reset "></center>

And the script as-

<script type="text/javascript" language="javascript">
var ld = load.value;
if (ld<10)
{
document.write("<b>Consumer's Category: Domestic-A</b>");
}
else if (ld>10 && ld<20)
{
document.write("<b>Consumer's Category: Domestic-B</b>");
}
else
{
document.write("<b>Consumer's Category: Commercial</b>");
}

Any help would be appreciated


santhosh_89
Novice

Jun 2, 2009, 9:33 PM

Post #2 of 2 (21460 views)
Re: [saturn] Capturing value entered in textfield of form and using in javascript code [In reply to] Can't Post

 Way -1
Once posting the value to next form,to store the POST method values to the hidden box,Actually there you will be running a java script,Now you will be able to access the hidden boxes,So you can get the value,But it is not security way,
Way -2
You can access paret and top methods to get the distance form values,
Example:
parent.Docuemnt.GetElementById('field_name').value;

If there any difficult call me....


(This post was edited by santhosh_89 on Jun 2, 2009, 9:35 PM)

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives