PDA

View Full Version : Ajax: vbullein_profiefield.js


senior01
01-06-2015, 01:06 PM
Hello,

this is exacly the code what i need for my new template.
on my new template i need to place two buttons to work whit them.
i hang on one row an dont understand, why getElementsByTagName don't to find the "form" TAG?

Answer from C.responseXML.getElementsByTagName('team_template")[0].firstChild.nodeValue

response = <form>
<fieldset>
<div>
<input type="text" class="primary textbox" name="postid[43473]" id="cfield_43473" value="Das Forum..." tabindex="1" maxlength="100" />
<p class="description">Das Forum</p>
<input type="hidden" name="postid[43473_set]" value="1" />
<div id="field_edit_error_container" class="hidden">
<img class="inlineimg" src="images/Seamus/statusicon/wol_error.png" alt="Fehler" />
<span id="field_edit_errors"></span>
</div>
<div>
<input type="submit" id="submitbutton" class="userprof_button" value=" Speichern " />
<input type="reset" id="cancelbutton" class="userprof_button" value="Abbrechen" />
<img class="hidden" id="field_edit_progress" src="images/Seamus/misc/progress.gif" alt="" />
</div>
</div>
</fieldset>
</form>


cmd:
this.element.innerHTML = C.responseXML.getElementsByTagName("template")[0].firstChild.nodeValue;
this.form = this.element.getElementsByTagName("form")[0];

for (var B = 0; B < this.form.elements.length; B++) {
if (this.form.elements[B].tagName == "INPUT" || this.form.elements[B].tagName == "SELECT" || this.form.elements[B].tagName == "TEXTAREA") {
this.form.elements[B].focus();
break
}
}

console.log:
vbulletin_team_edit.js?v=422:100 form? = undefined

vbulletin_team_edit.js?v=422:105 Uncaught TypeError: Cannot read property 'elements' of undefined
vbulletin_team_edit.js?v=422:64


if i change the tag from "form" to other tag like "p" then,
the log console says that they accept the other tag, but i need in this case the "form" tag.
If i try it to get it with "getElementbyID" or "getElementsbyID" it shows me the answer that the Function ist not defined,

console.log:
element = [object HTMLElement]

sorry for my bad english....


Best Regards,
Senior

kh99
01-06-2015, 02:13 PM
Is this.element already inside a form? I think if you try to create a form inside another form you might end up with the problem you are having.

senior01
01-06-2015, 02:53 PM
you are right :)

many thanks for your help!


Best Regards,
Senior

ozzy47
01-06-2015, 09:41 PM
@senior01, next time you post code, could you please wrap it in code tags, like this. Thanks. :)

Answer from C.responseXML.getElementsByTagName('team_template")[0].firstChild.nodeValue

response = <form>
<fieldset>
<div>
<input type="text" class="primary textbox" name="postid[43473]" id="cfield_43473" value="Das Forum..." tabindex="1" maxlength="100" />
<p class="description">Das Forum</p>
<input type="hidden" name="postid[43473_set]" value="1" />
<div id="field_edit_error_container" class="hidden">
<img class="inlineimg" src="images/Seamus/statusicon/wol_error.png" alt="Fehler" />
<span id="field_edit_errors"></span>
</div>
<div>
<input type="submit" id="submitbutton" class="userprof_button" value=" Speichern " />
<input type="reset" id="cancelbutton" class="userprof_button" value="Abbrechen" />
<img class="hidden" id="field_edit_progress" src="images/Seamus/misc/progress.gif" alt="" />
</div>
</div>
</fieldset>
</form>


cmd:
this.element.innerHTML = C.responseXML.getElementsByTagName("template")[0].firstChild.nodeValue;
this.form = this.element.getElementsByTagName("form")[0];

for (var B = 0; B < this.form.elements.length; B++) {
if (this.form.elements[b].tagName == "INPUT" || this.form.elements[b].tagName == "SELECT" || this.form.elements[b].tagName == "TEXTAREA") {
this.form.elements[b].focus();
break
}
}

console.log:
vbulletin_team_edit.js?v=422:100 form? = undefined

vbulletin_team_edit.js?v=422:105 Uncaught TypeError: Cannot read property 'elements' of undefined
vbulletin_team_edit.js?v=422:64

senior01
01-07-2015, 11:40 AM
sorry, i have forget to set the code inside tag.

thanks :)

Best Regards,
Senior