פורסם 2007 בספטמבר 2717 שנים שלום לכולם,אני רוצה להשתמש בקוד שקיים באתר הנ"ל:http://www.codeproject.com/jscript/TableFilter.aspעם שינוי מסוים שאני לא יודע איך עושים אותו ואשמח אם מישהו יוכל לעזור לי או לשלוח לי קוד המאפשר זאת כי אני לא בדיוק מתמצא ב-JS.כפי שניתן לראות באתר ניתן להזין את השדה הרצוי לחיפווש או לסנן מתוך רשימה.במקום האפשרויות הנ"ל, אני רוצה שיהיו לינקים שמהם יבוצע החיפוש, לדוגמא :יהיה לינק שבו רשום המילה "Joe" ובעת לחיצה על המילה תבצע את החיפוש ותציג לי רק את האפשרויות שעונות על החיפוש בטבלה...איך עושים את זה, מישהו יכול לעזור לי ?תודה מראש.
פורסם 2007 בספטמבר 2717 שנים 1) זה לא עובד בFF.2) <input type="button" value="Joe" TF_colKey="name" TF_searchType="full" onkeyup="TF_filterTable(dataTable, filter)">תנסה, אולי יעבוד(לא ניסיתי בעצמי).עריכה: ד.א. שים לב שהוא מבחין בין אותיות גדולות לקטנות. אולי כדאי לך לשנות את זה.
פורסם 2007 בספטמבר 2817 שנים מחבר עדיין לא קורה כלום.נראה כאילו value="Joe" לא מחזיר לו ערך וזה ערך לתצוגה לכפתור ולא כערך לחיפוש (כאילו הוא ריק).האם ניתן להשתמש ב-getElementById כדי שיקבל ערך ?
פורסם 2007 בספטמבר 2817 שנים מאפיין הVALUE מסמן את הערך שתג הINPUT מכיל. כפי שVALUE של TEXT מכיל את הטקסט עצמו(בסך הכל ייצוג גרפי שונה של אותו דבר).תכניס את זה לFORM שיש שם.אתה מקבל שגיאות כלשהן ב JS CONSOLE?
פורסם 2007 בספטמבר 2817 שנים מחבר לא מתקבלות JS ERROR ...נראה שהכפתור לא מבצע שום פעולה, זה עובד רק כאשר מבצעים הזנה ידנית.את מה להכניס ל-form ?
פורסם 2007 בספטמבר 2917 שנים שים לב למה שבאדום אתה פשוט צריך להוסיף בפונקציות של הג'וואה סקריפט את התייחסות למקרה של כפתור הכיל את הפרמטרים והערךלדעתי זה יפתור לך הבעיה function _TF_shouldShow(type, con, cell) { var toshow=true; if (type != null) type = type.toLowerCase(); switch (type) { case "checkbox": //condition is for checkbox //so lets find out if the cell contains a checkbox var aInputs = cell.all.tags("INPUT"); //check for input tags for (var i=0;i<aInputs.length;i++) { //and look for the first checked item if (aInputs[i].type == "checkbox") { toshow = (con.toLowerCase() == (aInputs[i].checked?"true":"false")); if (toshow) break; } } break case "item": var strarray = cell.innerText.split(","); innershow = false; for (var ss=0;ss<strarray.length;ss++){ if (con==_TF_trimWhitespace(strarray[ss])){ innershow=true; break; } } if (innershow == false) toshow=false; break case "full": if (cell.innerText!=con) toshow = false; break case "substring": if (cell.innerText.indexOf(con)<0) toshow = false; break [color=red]case "button": //write the code to handle the data from the input button break[/color] default: //is "substring1" search if (cell.innerText.indexOf(con)!=0) //pattern must start from 1st char toshow = false; if (con.charAt(con.length-1) == " ") { //last char is a space, so lets do a full search as well if (_TF_trimWhitespace(con) != cell.innerText) toshow = false; else toshow = true; } break } return toshow;}function TF_filterTable(tb, frm) { var conditions = new Array(); if (frm.style.display == "none") //filtering is off return _TF_showAll(tb); //go thru each type of input elements to figure out the filter conditions var inputs = frm.tags("INPUT"); for (var i=0;i<inputs.length;i++) { //looping thru all INPUT elements if (inputs[i].getAttribute("TF_colKey") == null) //attribute not found continue; //we assume that this input field is not for us switch (inputs[i].type) { [color=red]case "button": //write the code to handle the data from the input button break[/color] case "text": case "hidden": if(inputs[i].value != "") { index = conditions.length; conditions[index] = new Object; conditions[index].name = inputs[i].getAttribute("TF_colKey"); conditions[index].type = inputs[i].getAttribute("TF_searchType"); conditions[index].value = inputs[i].value; conditions[index].single = true; } break case "checkbox": if(inputs[i].isDisabled == false) { index = conditions.length; conditions[index] = new Object; conditions[index].name = inputs[i].getAttribute("TF_colKey"); conditions[index].type = "checkbox"; conditions[index].value = inputs[i].checked?"true":"false"; conditions[index].single = true; } break } } var inputs = frm.tags("SELECT"); //able to do multiple selection box for (var i=0;i<inputs.length;i++) { //looping thru all SELECT elements if (inputs[i].getAttribute("TF_colKey") == null) //attribute not found continue; //we assume that this input field is not for us var opts = inputs[i].options; var optsSelected = new Array(); for (intLoop=0; intLoop<opts.length; intLoop++) { //looping thru all OPTIONS elements if (opts[intLoop].selected && (opts[intLoop].getAttribute("TF_not_used") == null)) { index = optsSelected.length; optsSelected[index] = opts[intLoop].value; } } if (optsSelected.length > 0) //has selected items { index = conditions.length; conditions[index] = new Object; conditions[index].name = inputs[i].getAttribute("TF_colKey"); conditions[index].type = inputs[i].getAttribute("TF_searchType"); conditions[index].value = optsSelected; conditions[index].single = false; } } //ok, now that we have all the conditions, lets do the filtering proper _TF_filterTable(tb, conditions);}function _TF_get_value(input) { switch (input.type) { [color=red]case "button": //write the code to handle the data from the input button break[/color] case "text": return input.value; break case "select-one": if (input.selectedIndex > -1) //has value return input.options(input.selectedIndex).value; else return ""; break; }}
פורסם 2007 בספטמבר 2917 שנים בפונקציות TF_FilterTable וב TF_get_valueתוסיףcase "button":בשורה לפני.case "text":
פורסם 2007 בספטמבר 2917 שנים מחבר גם לא טוב אבל יש שיפור.כעת מתבצע חיפוש לפי ערך אחד בלבד.כלומר אם יצרתי 2 כפתורים שלכל אחד יש ערך שונה (joe,dan), הוא מחזיר לי כל פעם רק את הערך joe.הסבר:אם אני לוחץ על joe הוא מחזיר לי את joe, אך שים לב אם אני לוחץ על dan הוא מחזיר לי גם את joe....אני מתחיל להתייאש...
פורסם 2007 בספטמבר 2917 שנים <input type="button" value="Dan" TF_colKey="name" TF_searchType="full" onmousedown="TF_filterTable(dataTable, filter)">שים לב שהחלפתי את Joe ב Dan. תעשה ככה לכל השמות שאתה צריך.
פורסם 2007 בספטמבר 2917 שנים מחבר זה מה שעשיתי גם מקודם:<input type="button" value="Joe" tf_colKey="name" tf_searchtype="full" onmousedown="TF_filterTable(dataTable, filter)"><input type="button" value="Dan" tf_colKey="name" tf_searchtype="full" onmousedown="TF_filterTable(dataTable, filter)">לא עובד...
ארכיון
דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.