Jump to content

not sure why this issn't working


severndigital

Recommended Posts

all i want to do is submit a form when i onblur some text field.

i keep getting the error that it's not defined.

 

here is the code i have

function submitForm(formName){
document.formName.submit();
}

 

here is the html i am trying to use with that.

<form action="?operation=update" method="post" name="ElementForm-1" />
<input name="fontSize" type="text" class="textFormField" size="2" maxlength="3" value="<?php echo $this->_elemFontSize; ?>" onblur="submitForm('ElementForm-1')"/>
</form>

 

when i run it i get the error

document.formName is undefined

 

anyone help me out??

 

Thanks,

-C

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Link to comment
Share on other sites

function submitForm(formName){
formName.submit();
}

<form action="?operation=update" method="post" name="ElementForm-1" />
<input name="fontSize" type="text" class="textFormField" size="2" maxlength="3" value="<?php echo $this->_elemFontSize; ?>" onblur="submitForm(this.form)"/>
</form>

Try that.

Link to comment
Share on other sites

<form action="?operation=update" method="post" name="ElementForm-1" />
<input name="fontSize" type="text" class="textFormField" size="2" maxlength="3" value="<?php echo $this->_elemFontSize; ?>" onblur="this.form.submit();"/>
</form>

Link to comment
Share on other sites

<form action="?operation=update" method="post" name="ElementForm-1" />
<input name="fontSize" type="text" class="textFormField" size="2" maxlength="3" value="<?php echo $this->_elemFontSize; ?>" onblur="document.ElementForm-1.submit();"/>
</form>

Link to comment
Share on other sites

Why the old school stuff?

 

There is such thing known as document.getElementById().

 

Example:

<form name="form" id="form" method="post" action="http://www.google.com">
<input type="text" name="textfield" id="textfield" value="onBlur me and I'll go to Google!" onblur="javascript: document.getElementById('form').submit()" />
</form>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.