header

Conflicting form action element and property

Problem:
I recently came across an issue where an HTML input element named “action” was conflicting with the enclosing form’s action property. To clarify, there was a form setup thusly:

<form action="index.php" method="post" name="searchForm" id="searchForm">
...
<a onclick="changeAction();">Export File</a>
<input type="hidden" name="action" value="1" />
...
</form>

Where the changeAction function is defined as

<script>
function changeAction(){
 var x = document.getElementById("searchForm");
 alert("original action: "+x.action);
 x.action = 'export_csv.php';
 alert("new action: "+x.action);
 x.submit();
}
</script>

I found this function on w3schools, and I was trying to figure out why it wouldn’t work for me. It worked fine in Firefox, but not IE. It finally occurred to me that in IE, document.getElementById(“searchForm”).action was the same as document.getElementById(“action”) — that is to say the .action was not the form’s action property, it was actually pointing to the input HTML element instead. I would argue that this is a bug with IE, that any input named ‘action’ would overwrite any direct access to the action form property.

This made it seemingly impossible for me to dynamically change the action of a form with the conflicting named input item.

The obvious solution is to change the name of the input. For most that would probably work OK, but I didn’t like that solution. I HAD to get it ;) .

Solutions:
The first thing I tried was removing the input, then submitting the form. This would work for most. So that involved:

  1. Enclosing the input with a span with an ID I could reference — ‘action_input’.
  2. Changing the changeAction function to clear the innerHTML of ‘action_input’, then submit.

This works fine for most. However, for me the new action I am setting retains the current page, it does not do a new page load. This means that I need to be able to reset the action value after submitting, and it appears as though setting the innerHTML after a submit() does not work so well cross browser.

I asked for help on efnet’s #javascript (IRC), and I was directed to the javascript function setAttribute. After some searching, I found that this doesn’t work; in IE the getAttribute(“action”)/setAttribute(“action”, “newVal”) functions STILL reference the HTML input element, not the action property of the form.

Upon more searching, I was directed to the changelog for AjaxAnywhere:

1.1.0.2 – evolution : form “action” attribute is accessed by DOM to prevent collision with <input name=”action” .. >

(Hey, at least someone else had this same issue!)

I perused their source code, and found this snippet (aa.js, line 130):

var actionAttrNode = form.attributes["action"];

So I tried that, and it worked beautifully in IE6, IE7 and Firefox 2. The adjusted javascript function:

function changeAction(){
 var x = document.getElementById("searchForm");
 x.attributes["action"].value = 'export_csv.php';
 x.submit();
 x.attributes["action"].value = 'index.php';
}

Update: makk on efnet #javascript says that this doesn’t work with Safari. There’s a workaround which makes it work, which I applied. Here’s the final version of the function:

function changeAction(){
 var x = document.getElementById("searchForm");
 x.attributes.getNamedItem('action').value = 'export_csv.php';
 x.submit();
 x.attributes.getNamedItem('action').value = 'index.php';
}

Problem solved!

Comments (1)

Tom’s Inspiron 6000 Power Adapter

Tom came over today with his laptop, hoping to get some help in fixing a busted power adapter connection. He said that when he had the adapter plugged into the laptop, it would sometimes charge the battery and sometimes not. He narrowed down the issue to the connector on the laptop’s motherboard, so he bought a replacement and needed to have it soldered on.

I asked Pat (my father in law) to help me diagnose and fix the issue. Tom and I opened up the laptop, and removed the motherboard from the case via the Dell Inspiron 6000 Service Manual. We flipped the motherboard over, then examined the leads on the motherboard, and noticed that a few of them were burnt out… not even connected.

So Pat redid the solder points, then we put the laptop back together, and wha-la, it worked. It’s nice when things work out first try…

Check out the pics:

Comments (3)

24

One year for every episode, except I’m cooler than Jack Bauer.

Comments (4)

Dell Vostro 1500 Review

Introduction
I sold my previous laptop, a Dell Inspiron 700m 12″ notebook, and shortly after I purchased a Dell Vostro 1500 15″ notebook. I’ve had it for a month and a half now, long enough to make a balanced review.

Dell Vostro 1500
Click to see my hi-res Flickr photoset of the Dell Vostro 1500

Build Specifications
I purchased the laptop as a default build, with the exception of the screen, warranty and graphics card. The specs were:

  • Intel® Core™ 2 Duo T5470 (1.6GHz, 2MB L2 Cache, 800MHz FSB)
  • Genuine Windows® XP Home
  • 15.4 in Wide Screen SXGA+LCD (1680×1050) Display w/TrueLife™ — Default is the 1280×800
  • 1GB Shared Dual Channel DDR2 SDRAM at 667MHz, 2 DIMM
  • 256MB NVIDIA® GeForce™ 8600M GT — Default is the 8400
  • 120G 5400RPM SATA Hard Drive
  • Integrated 10/100 Network Card and Modem
  • 8X CD/DVD Burner w/ double-layer DVD+R write capability
  • High Definition Audio 2.0
  • Dell Wireless 1390 802.11g Wi-Fi Mini Card
  • 56 WHr 6-cell Lithium Ion Primary Battery
  • Get $70 Dell Dollars w/3Yr Ltd Warranty and Next Business Day On-Site Svc — Default is 1 year

Final price: $968.00, with free next day delivery. Shortly after I ordered, Dell was giving away free webcams on the LCD, but my order was too late. Subsequently, they gave me a $50 voucher for the difference. That effectively made the final price $918.00.

As soon as I found a deal, I bought a 2×1GB Memory upgrade, “Patriot 2GB (2×1GB) PC2-5300 DDR2 667MHz CL5 200-Pin SO-DIMM”. Aftermarket RAM is always going to be cheaper than ordering it preconfigured with the notebook. I installed the memory via a guide I found, it was easy, took about 20 minutes from powering the laptop down with 1GB to powering it up with 2GB of RAM. Final price including the RAM upgrade: $972.00.

It’s hard to go from a 12″ to a 15″ notebook, but not nearly as hard as it was to go from a 15″ to a 12″ notebook. The hardest things for me to get used to were the new key sizes and the new key placements on the keyboard. The graphics on my 12″ were very sub-par, so comparatively this laptop performs exceedingly well.

Gaming
So far this laptop has played every game I put on it flawlessly, at full settings. I’ve yet to bring it to a LAN party, but given that it’s more powerful than my desktop in every way, I doubt I will be using the desktop for gaming “because my laptop can’t handle it” anymore. The games I play most often on my PC are

  • Warcraft 3: Frozen Throne custom map Defense of the Ancients: Allstars
  • Counter-strike: Source

Admittedly not the most impressive game repertoire, but that will change in time.

I was able to adjust the settings to max for every option on Counter-strike: Source. I could notice a slight lag, but I was still getting 40fps easily.

A few times inside of a game, I’ve had my graphics driver fail, which either causes the system to lockup, or revert graphics to 800×600x16 and not allow correction until reboot. This happens so rarely I won’t really know that it’s fixed. I’ve had the same issue on other systems, other graphics cards, other drivers. I’m certain that there will be an updated graphics driver that will fix it and not mention anything about it in the changelog, so it’s almost not even worth mentioning.

Appearance
The Vostro 1500 has a sleak brushed-looking black Magnesium-alloy chassis. This makes it more rigid looking and feeling than the previous plastic chassis of the Inspirons. Unfortunately, this makes the case very sensitive to fingerprint markings, as can be seen in this picture:
Dell Vostro 1500
No, I didn’t just eat some greasy potato chips and plant my fingers all over this before taking the picture. It’s overly sensitive and shows its markings. This might be a turn-off to some people, not to me.

The latch that holds the lid closed is very cheap and flimsy feeling, and doesn’t come to a snug close. I’ve heard stories of people breaking this off already, and I’m sure (ironically) that it’s not a cheap replacement. Once the lid is closed, there’s a fraction of a millimeter between the screen and the keyboard, just enough so that pressure upon the back of the screen will make it feel like it’s moving toward and away from the keyboard. That’s a little nerveracking, and I feel it detracts quite heavily from the quality of the notebook.

It feels like the hinge that connects the screen to the base is too tight, it’s impossible for me to open the screen from closed position with one hand. This is just a minor annoyance, but it’s constant. Every time I have to put down something in hand #2 to help hand #1 open the screen, I get just a little bit more annoyed at the notebook.

There are some obvious draws to the default specs of the Vostro. It is pretty thick and heavy, and the battery life is less than optimal compared to some other notebooks in its class. I don’t mind it, in fact I prefer it. I’ve had a portable laptop in the past, and frankly I find more use to a decently priced desktop replacement. I guess what I’m trying to say, is if I could get away from paying extra for a lighter, longer-charged, thinner notebook, I would…, and I did. That being said, I was still able to get almost 2 hours of battery life with casual use — more than I’d need.

Administrativa
One of the selling points of the laptop is that it doesn’t come prebundled with Dell’s bloatware. The bloatware never really affected me too much. I ordered the Vostro with Windows XP Home, because I have my student license of Windows XP Pro with which I planned to wipe the hard drive as soon as I received the laptop. I did just that, and found the drivers from Dell’s Vostro 1500 driver page without any problems; every device worked. At some point in the past month and a half, Dell decided to no longer host the Windows XP drivers for the Vostro 1500, now you can only select “Windows Vista 32-bit” as your Operating System. Now this is not to say the drivers they have listed won’t work with Windows XP, it just means that they’re working toward no longer supporting XP on the 1500. This is very discouraging, considering I don’t have a student license of Windows Vista :) . As of Oct-12th, Windows XP is available again. It must have just been a temporary outage.

Two or three times since I’ve received the laptop, I would get weird BIOS messages, saying something to the effect that “the battery is not found or not supported.” I wish I would have captured this image to find out more about what it means, but since pressing F3 to ignore has been working, I’ve been content with that thus far. Next time I get it, I’ll be sure to capture it and followup with that error message.

Conclusion
This is only the second laptop I’ve owned or used very heavily, the first being my Dell Inspiron 700m. I’m very impressed with the power of the unit, Dell has made it very customizable and upgradable. There are quite a few shortcomings, this is really Dell’s first shot at a Magnesium-alloy chassis. However, I applaud their efforts, and I couldn’t be happier with the result.

Score: 9.0/10

Links of Interest:
My Dell Vostro 1500 photoset at Flickr.com
Dell Vostro 1500 Driver Page at Dell.com
Dell Vostro 1500 Manuals at Dell.com

Comments (31)

Beta Testing Defensio

Akismet isn’t perfect. I’ve been using it to block my spam since it became available. One of its major problems is that it often lets through what Defensio calls URL-less spam, and sometimes less through spam WITH urls, which I don’t quite understand.

Anyway, so right after this post, I’ll be disabling Akismet and turning on Defensio Beta. I’ll be monitoring spam incoming, ham incoming, speed of page loads, etc. If you notice anything funky, let me know :)

Comments (0)


blogtimes