Jump to content

Javascript porblem


ericwongch

Recommended Posts

<script language="javascript"><!-- function getNum() { var num = 12345; return num; }//--></script><from name="myform" action="xxx.jsp" method="get"><input name="number1" type="text"></input><input name="number2" type="hidden" value="getNum()"></input><input type="submit" value="Click me"></from>the problem is i can't get the value of getNum()how can i dothx... :)

Link to comment
Share on other sites

Your code is quite sloppy man :) several errors!!<from> should be <form></input> = no such thing, this tag self closes, use <input type="text" />getNum() is never called, you need to add an event handler, like onsubmit()Try this code:

<script language="javascript"><!--function getNum() {var num = 12345;document.getElementById('number2').value=num;}//--></script><form name="myform" action="xxx.jsp" method="get" onsubmit="getNum()"><input id="number1" type="text" /><input id="number2" type="hidden" /><input type="submit" value="Click me" /></form>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...