Bug Tracker

Ticket #4299: jQueryBug.html

File jQueryBug.html, 1.7 KB (added by soswow, 5 years ago)

Example to Bug #4299

Line 
1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2<html xmlns="http://www.w3.org/1999/xhtml">
3<head>
4        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
6        <title>jQuery bug</title>
7       
8<script type="text/javascript">
9$(function(){ 
10  doChanges("form1");
11  doChanges("form2");
12});
13
14function log(msg){
15  $("#logger").append(msg + "<br/>"); 
16}
17
18function doChanges(formid){
19  log("+++++++++++++++++");
20  log("Working with formid = "+formid);
21  var $form = $("#"+formid);
22 
23  testFieldChanging($form, "action", "#newAction");
24  log(" ");
25  testFieldChanging($form, "method", "post");
26}
27
28function testFieldChanging($form, fieldName, newAttr){
29  log("Start "+fieldName+" attr = " + $form.attr(fieldName));
30  log("Changing "+fieldName+" attr to "+newAttr);
31 
32  $form.attr(fieldName, newAttr);
33 
34  log("Now "+fieldName+" attr = "+ $form.attr(fieldName));
35  var actionResult = ($form.attr(fieldName).toLowerCase() === newAttr.toLowerCase() )?"<span style='color:green;'>CHANGED</span>":"<span style='color:red;'>NOT CHANGED</span>";
36  log("Result: "+fieldName+" attr is "+actionResult);
37}
38</script>
39
40</head>
41<body>
42
43<form id="form1" action="#action1" method="get">
44  <!-- Nothing here -->
45</form>
46
47<form id="form2" action="#action2" method="get">
48  <!-- Nothing here -->
49  <input type="text" name="action" value="Action Start Value" />
50  <input type="text" name="method" value="Method start Value" />
51</form>
52
53
54<div id="logger">
55
56</div>
57</body>
58</html>