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
https://forums.phpfreaks.com/topic/131401-not-sure-why-this-issnt-working/
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.

<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>

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>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.