[Picfinity-commit] SF.net SVN: picfinity: [62] trunk/.themes/db/db.js
Status: Beta
Brought to you by:
espadav8
From: <esp...@us...> - 2007-09-01 17:59:42
|
Revision: 62 http://picfinity.svn.sourceforge.net/picfinity/?rev=62&view=rev Author: espadav8 Date: 2007-09-01 10:59:43 -0700 (Sat, 01 Sep 2007) Log Message: ----------- Allow createFormInput to create other input types by passing in the type required In IE use the IE-only way to set the name of the form inputs Since IE doesn't allow buttons to set the type in JS, the button now has an onclick instead which runs the addNewComment function Remove the form action and onsubmit from the JS since it's not needed now Modified Paths: -------------- trunk/.themes/db/db.js Modified: trunk/.themes/db/db.js =================================================================== --- trunk/.themes/db/db.js 2007-09-01 16:16:32 UTC (rev 61) +++ trunk/.themes/db/db.js 2007-09-01 17:59:43 UTC (rev 62) @@ -433,27 +433,19 @@ addCommentSpan.appendChild(addCommentAnchor); var commentForm = document.createElement("form"); - commentForm.onsubmit = addNewComment; - commentForm.action = ".themes/db/addComment.php"; commentForm.style.display = "none"; var commentFormFieldset = document.createElement("fieldset"); - var ajaxInput = document.createElement("input"); - ajaxInput.type = "hidden"; - ajaxInput.value = "0"; - ajaxInput.name = "ajax"; + var ajaxInput = createFormInput("hidden", "ajax", "0"); + var imageIDInput = createFormInput("hidden", "image_id", imageID); - var imageIDInput = document.createElement("input"); - imageIDInput.type = "hidden"; - imageIDInput.value = imageID; - imageIDInput.name = "image_id"; - - var nameLabel = createFormInput("user_name", "Name:"); - var emailLabel = createFormInput("user_email", "Email:"); - var webLabel = createFormInput("user_web", "Web:"); + var nameLabel = createFormInput("text", "user_name", "Name:"); + var emailLabel = createFormInput("text", "user_email", "Email:"); + var webLabel = createFormInput("text", "user_web", "Web:"); var commentLabel = createFormTextarea("user_comment", "Comment:"); var submitButton = createFormButton("submit", "Submit"); + submitButton.onclick = addNewComment; commentFormFieldset.appendChild(ajaxInput); commentFormFieldset.appendChild(imageIDInput); @@ -471,20 +463,45 @@ return commentFormDiv; } -function createFormInput(inputName, spanText) +function createFormInput(inputType, inputName, spanText) { - var tmpLabel = document.createElement("label"); - var tmpSpan = document.createElement("span"); - tmpSpan.appendChild(document.createTextNode(spanText)); - var tmpInput = document.createElement("input"); - tmpInput.type = "text"; - tmpInput.value = ""; - tmpInput.name = inputName; + if (inputType == "hidden") + { + if (document.all) + { + var tmpInput = document.createElement("<input name=\"" + inputName + "\">"); + } + else + { + var tmpInput = document.createElement("input"); + tmpInput.name = inputName; + } + tmpInput.type = inputType; + tmpInput.value = spanText; - tmpLabel.appendChild(tmpSpan); - tmpLabel.appendChild(tmpInput); + return tmpInput; + } + else + { + var tmpLabel = document.createElement("label"); + var tmpSpan = document.createElement("span"); + tmpSpan.appendChild(document.createTextNode(spanText)); + if (document.all) + { + var tmpInput = document.createElement("<input name=\"" + inputName + "\">"); + } + else + { + var tmpInput = document.createElement("input"); + tmpInput.name = inputName; + } + tmpInput.type = inputType; + tmpInput.value = ""; - return tmpLabel; + tmpLabel.appendChild(tmpSpan); + tmpLabel.appendChild(tmpInput); + return tmpLabel; + } } function createFormTextarea(textareaName, spanText) @@ -492,8 +509,15 @@ var tmpLabel = document.createElement("label"); var tmpSpan = document.createElement("span"); tmpSpan.appendChild(document.createTextNode(spanText)); - var tmpTextarea = document.createElement("textarea"); - tmpTextarea.name = textareaName; + if (document.all) + { + var tmpTextarea = document.createElement("<textarea name=\"" + textareaName + "\">"); + } + else + { + var tmpTextarea = document.createElement("textarea"); + tmpTextarea.name = textareaName; + } tmpTextarea.rows = 3; tmpTextarea.cols = 50; @@ -863,7 +887,6 @@ function addNewComment() { - alert("Adding a comment"); if (window.XMLHttpRequest) { var commentForm = document.getElementById("commentform").getElementsByTagName("form")[0]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |