开发者

Javascript Form submission: undefined

This must be a simple problem but i can't figure out why i开发者_运维技巧t's not working. The script shall pass values of the tags field to a script on the same page.

<FORM id="form" METHOD="" ACTION="#" >
<input size="40" name='tags' id='tags' onSubmit="javascript: submitForm(this)">
<INPUT TYPE="submit" id='q' VALUE="Submit" >
<INPUT TYPE="reset" VALUE="Reset">
</FORM>
<div id='info'>This sentence will be replaced</div>

<script>

var tags;

function submitForm(form)
{
    tags = form.tags.value
    return false ;
}
alert(tags)
...
</script>

alert box says: undefined


You run that alert before running submitForm(). Try moving alert(tags) before return false;, inside submitForm(form).

function submitForm(form)
{
 tags = form.tags.value;
 alert(tags);
 return false ;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜