Hi,
it looks very basic thing but i could not figure it out.
var email = $("input#email").val();
how can i check if that email variable has @ letter ?
Thanks
I have a simple Post model with a m2m field to a Tag model.
The Tag had for some reason to use a non default primary key.
Inside the admin page for a Post, the labels for the multiple selection field for Tags appear, but not the input field itself. I also tried using the filter_horizontal for the tags, but still only the labels appear without the actual field.
Any ideas why it breaks and/or workarounds?
Thanks!
I have a basic Edit method in my controller that redirects back to a top level listing (“Index”) when the edit succeeds. Standard setup after scaffolding.
I am trying to change this Edit method to redirect back to the previous page (not Index). Since my Edit method is not using the default mapped input parameter “id”, I am using that to pass the previous URL.
In my Edit “get” method, I use this line to grab the previous URL and it works fine:
ViewBag.ReturnUrl = Request.UrlReferrer.AbsoluteUri;
I send this return URL to the Edit “post” method by using my form tag like this:
@using (Html.BeginForm(new { id = ViewBag.ReturnUrl }))
Now this is where the wheels fall off. I can't seem to get the URL parsed from the id parameter properly.
UPDATE****
Using Gary's example as a guide, I changing my parameter name from "id" to "returnUrl" and used a hidden field to pass my parameter. Lesson: Only use the id parameter how it was intended to be used...keep it simple. It works now... Here is my updated code.
//
// GET: /Question/Edit/5
public ActionResult Edit(int id)
{
Question question = db.Questions.Find(id);
ViewBag.DomainId = new SelectList(db.Domains, "DomainId", "Name", question.DomainId);
ViewBag.Answers = db.Questions
.AsEnumerable()
.Select(d => new SelectListItem
{
Text = d.Text,
Value = d.QuestionId.ToString(),
Selected = question.QuestionId == d.QuestionId
});
ViewBag.returnUrl = Request.UrlReferrer;
ViewBag.ExamId = db.Domains.Find(question.DomainId).ExamId;
ViewBag.IndexByQuestion = string.Format("IndexByQuestion/{0}", question.QuestionId);
return View(question);
}
//
// POST: /Question/Edit/5
[HttpPost]
public ActionResult Edit(Question question, string returnUrl)
{
int ExamId = db.Domains.Find(question.DomainId).ExamId;
if (ModelState.IsValid)
{
db.Entry(question).State = EntityState.Modified;
db.SaveChanges();
//return RedirectToAction("Index");
return Redirect(returnUrl);
}
ViewBag.DomainId = new SelectList(db.Domains, "DomainId", "Name", question.DomainId);
return View(question);
}
and I changed my form tag to this:
@using (Html.BeginForm())
{
<input type="hidden" name="returnUrl" value="@ViewBag.returnUrl" />
Thanks Gary
What is the best method, if there is one, of using Wordpress as a CMS for users to input data while not actually building the website on the Wordpress platform?
One possible solution I've found is using a PHP class called "WPGet" (http://peter.upfold.org.uk/projects/wpget) which fetches directly from the database.
It is known that the halting problem cannot have a definite solution, one that a) returns true <== the program does indeed halt, and b) handles any input, but I was wondering if there are good enough solutions to the problem, ones that can maybe handle certain types of program flows perfectly, or is able to identify it when it cannot correctly solve the problem, and so on....
If so, how good are they, and what ideas/limitations do they rely on?
New to VBA, please help. I have a range say A2:D10; input causes rows to be added. New entries are being added using NextRow=_. Works perfectly, however, how do I get the formulas in columns C and D to follow each new row being added. I cannot just format entire column due to my sort criteria. Example formula is =IF(ISTEXT($B11),$C$2-$D11,"")
Hello,
I wrote a datepicker in Javascript, but it is not working properly,
as I lose the reference to the Calender object.
here is the example
http://asexpress.de/calender/
by clicking within the input field the calender will be displayed.
What should I do that the reference to the Calender object remains in contact.
I am getting this "HTTP method POST is not supported by this URL" error when I run my project. The funny thing is, it was running perfectly fine two days ago. After I made a few changes to my code but then restored my original code and its giving me this error. Could you please help me?
Here is my index.html:
<form method="post" action="login.do">
<div>
<table>
<tr><td>Username: </td><td><input type="text" name="e_name"/>
</td> </tr>
<tr><td> Password: </td><td><input type="password" name="e_pass"/>
</td> </tr>
<tr><td></td><td><input type="submit" name ="e_submit" value="Submit"/>
Here is my Login servlet:
public class Login extends HttpServlet {
/**
* Processes requests for both HTTP
* <code>GET</code> and
* <code>POST</code> methods.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException, SQLException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
try {
/*
* TODO output your page here. You may use following sample code.
*/
int status;
String submit = request.getParameter("e_submit");
String submit2 = request.getParameter("a_submit");
out.println("Here1");
String e_name = request.getParameter("e_name");
String e_password = request.getParameter("e_pass");
String a_name = request.getParameter("a_name");
String a_password = request.getParameter("a_pass");
out.println(e_name+e_password+a_name+a_password);
Author author = new Author(a_name,a_password);
Editor editor = new Editor(e_name,e_password);
// If it is an AUTHOR login:
if(submit==null){
status = author.login(author);
out.println("Author Login");
//Incorrect login details
if(status==0) {
out.println("Incorrect");
RequestDispatcher view = request.getRequestDispatcher("index_F.html");
view.forward(request, response);
}
//Correct login details --- AUTHOR
else {
out.println("Correct login details");
HttpSession session = request.getSession();
session.setAttribute(a_name, "a_name");
RequestDispatcher view = request.getRequestDispatcher("index_S.jsp");
view.forward(request, response);
}
}
//If it is an EDITOR login
else if (submit2==null){
status = editor.login(editor);
//Incorrect login details
if(status==0) {
RequestDispatcher view = request.getRequestDispatcher("index_F.html");
view.forward(request, response);
}
//Correct login details --- EDITOR
else {
out.println("correct");
HttpSession session = request.getSession();
session.setAttribute(e_name, "e_name");
session.setAttribute(e_password, "e_pass");
RequestDispatcher view = request.getRequestDispatcher("index_S_1.html");
view.forward(request, response);
} }
out.println("</body>");
out.println("</html>");
} finally {
out.close();
}
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
super.doPost(req, resp);
}
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
super.doGet(req, resp);
}}
And my web.xml looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>2</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>2</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet>
<servlet-name>Login</servlet-name>
<servlet-class>controller.Login</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Login</servlet-name>
<url-pattern>/login.do</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
I use Glassfish v3 server - let me know anything else you need to know
Hello.
I have a task - draw smooth curve
input: set of points (they added in realtime)
current solution: I use each 4 points to draw qubic Bezier curve (1 - strart, 2 and 3rd - control points, 4- end). End point of each curve is start point for the next one.
problem: at the curves connection I often have "fracture" (angle)
Can you tell me, how to connect my points more smooth?
Thanks!
Hi i am developing an app for my QA department. I need to programically get how many phone numbers are there in the entire address book. No user input. Just click a button and then get how many phonenumbers are there in the ENTIRE addressbook.
Please email me at [email protected]
I can not get the form to submit with the button. The best luck I have had is to send a generic email with no data attached.
This is the code:
<input name="mailto: [email protected]" type="submit" onClick=mailto: [email protected] value="Submit Form" id="mailto: [email protected]" >
the value is: /frms/contact.con
Can anyone help????
Hi guys.
I'm creating a page that searches for an item and then be able to edit/update it. I was able to do it when it returns just one result but when it gives me multiple results I could only edit the very last item. Below is my code:
.......
$dj =$_POST[djnum];
$sql= "SELECT * From dj WHERE datajack LIKE '$dj%'";
$result = mysql_query($sql);
//more code in here//
while ($info =mysql_fetch_array($result)) {
// display the result
echo "<form action=\"dj_update.php\" method=\"POST\"><input type=\"hidden\" name=\"djnumber\" value=\"".$info['datajack']."\">";
echo "<tr><td>DJ ".$info['datajack']."</td>";
echo "<td>".$info['building']." </td>";
echo "<td>Rm ".$info['room']." </td>";
echo "<td>".$info['switch']." </td>";
echo "<td>".$info['port']." </td>";
echo "<td>".$info['notes']." </td>";
echo "<td style=\"text-align:center;\"><input type=\"Submit\" value=\"Edit\" ></td></tr>";
}
// more code here //
Then this is the screen shot of the result:
The idea is the user should be able to click on "Edit" and be able to edit/update that particular item. But when I click any of the Edit button I could only edit the last item. What am I missing here? Is there an easier way to do this?
Thanks guys and Happy new year!
I've got a few DOM elements, say text-field input A, B, C, and all of them have the property of 'onclick'. How do I find to which object a particular 'onclick' belongs?
In need to determine the angle(s) between two n-dimensional vectors in Python. For example, the input can be two lists like the following: [1,2,3,4] and [6,7,8,9].
Can anybody help me? Thanks in advance!
I would like to know how to create a php function that can be installed in php
just like the already built in functions like :
rename
copy
The main point I would like to achieve is a simple php function that can be called from ANY php page on the whole host without needing to have a php function within the php page / needing an include.
so simply I would like to create a function that will work like this :
location();
That without a given input string will output the current location of the file via echo etc
So two questions here: If I use <input type="button" onclick="validate()"> then the enter key wouldn't work. However, I can use type="submit" but how would I invoke validate()?
I am using sed to extract parts of an XML I am interested in:
sed '/<car car_id="BMW" year="1999"/,/</car>/p' input
So what I really would like to get back is:
...
Instead I get back a bunch of other car elements.
Am I doing something wrong here?
I have a text area on a view and am posting back the html contents. In VS 2008 and MVC 1.0 the following code successfully prevents input validation:
[HttpPost]
[ValidateInput(false)]
public ActionResult Index(int? id)
{
return View();
}
If I execute this code in VS 2010 / MVC 2.0 I always get this error:
A potentially dangerous Request.Form value was detected from the client (body="").
Any ideas?
Hi,
I have a line chart with four lines:
- Total
- A
- B
- C
It is a only a limited number of lines, and I want to allow the user to specify via input parameters what lines to show (i.e. ShowTotal, ShowA, ShowB, ShowC booleans).
Can it be done, and how?
Write an application that inputs one number consisting of FIVE digits from the user, separates the number into its individual digits and prints the digits separated from one another by three spaces each. For example, if the user types in the number 12345, the program should print
1 2 3 4 5
The following screen dump of result is for your reference.
Input a digit: 12345
Digits in 12345 = 1 2 3 4 5
How to convert binary, OCT, HEX to calculate the question?
this code generates problem [encountered problem of window] and close all the safari windows,
but this code is working fine with Internet Explorer. What will I do ?
have any alternative method for closing current opened window in every browser.
<input type='button' value='close' onclick='window.close()'>