473,416 Members | 1,764 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,416 software developers and data experts.

Need help creating form widgets in javascript (and more)

Hi,
First let me say that my knowledge of HTML and Javascript is fairly limited. But I am stuck in a situation of trying to adapt a website's shopping cart to a new one.

Here's the problem, the code contains thousands of 'Add to Cart' buttons that look almost identical to this HTML snippet spread across over hundred pages:

[HTML]<form>
<p align="center">
<select name="package" size="1" style="width: 170" style="font-weight: 700">
<option selected>Full Package $14.99</option><option>Just Disk $5.99</option></select><b>&nbsp;</b>
<input type="button" value="Add to Cart" onclick="addToCartSimple('DF-498','Student Bodies',this.form);return false;"
style="font-weight: 700">
</p>
</form>[/HTML]

What we want to accomplish is to switch the cart without having to modify these lines. Unfortunately every help reference I've been able to find online uses the 'form name' reference, as there is no name reference in the code above I need a solution using the passed (this.form) reference.

I figure since it all goes through a central javascript routine "addToCartSimple" I ought to be able to just modify that and have the routine add and change the form elements I need and submit it.

The code for the Form I would be simulating looks like this:

[HTML]<!-- BEGIN www.ecartsoft.com ADD TO CART CODE
<FORM ACTION="HTTP://www.ecartsoft.com/cgi-bin/cart.cgi" METHOD="POST">
<INPUT TYPE="HIDDEN" NAME="acc" VALUE="xxxxx">
<INPUT TYPE="HIDDEN" NAME="page" VALUE="add to cart">
<INPUT TYPE="HIDDEN" NAME="required" VALUE="item_name,item_price">
<INPUT TYPE="HIDDEN" NAME="minimum_quantity_limit" VALUE="">
<INPUT TYPE="HIDDEN" NAME="max_quantity_limit" VALUE="">
<INPUT TYPE="HIDDEN" NAME="quantity" VALUE="1">
<INPUT TYPE="HIDDEN" NAME="item_sku" VALUE="DF-399">
<INPUT TYPE="HIDDEN" NAME="item_name" VALUE="Americathon">
<INPUT TYPE="HIDDEN" NAME="item_description" VALUE="">
<INPUT TYPE="HIDDEN" NAME="item_price" VALUE="12.99">
<INPUT TYPE="HIDDEN" NAME="item_weight" VALUE="">
<INPUT TYPE="HIDDEN" NAME="item_tax_id" VALUE="non-taxable">
<INPUT TYPE="HIDDEN" NAME="item_discount" VALUE="">
<INPUT TYPE="HIDDEN" NAME="item_image_url" VALUE="">
<INPUT TYPE="HIDDEN" NAME="Coupon_Code" VALUE="">
<INPUT TYPE="HIDDEN" NAME="secret_word" VALUE="">
<INPUT TYPE="HIDDEN" NAME="ship_free" VALUE="NO">
<INPUT TYPE="HIDDEN" NAME="handling_fee" VALUE="2.00">
<INPUT TYPE="HIDDEN" NAME="drop_ship" VALUE="">
<INPUT TYPE="HIDDEN" NAME="item_vendor" VALUE="">
<INPUT TYPE="HIDDEN" NAME="ship_calculation_method" VALUE="USPSOnline">
<INPUT TYPE="SUBMIT" VALUE="BUY NOW">
</FORM>
--> END eCartsoft ADD TO CART CODE -->
[/HTML]
I would like for there to be no noticeable change visibly to the form on the screen.
I've been struggling with this for a couple days but so far I get maddening lack of anything happening when I click on the button no matter what I try. I think my biggest problem is not understanding how Form items are created in Javascript (I can manipulate those already craeted in HTML but as I said we need avoid changing the original HTML. (don't worry about what to do with the data from 'select' element, I'll be able to extrapolate how to work that in.)

Can someone help point me in the correct direction, or much more preferably code addToCartSimple() for me, as I am far out of my depths here?

Any help is much appreciated.
Garth
Jan 27 '07 #1
1 1557
acoder
16,027 Expert Mod 8TB
See the HTML DOM for forms here.

You can set the action, method, name, etc. attributes as well as submit the form.
Jan 29 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Adonis | last post by:
I am creating some widgets by inheriting from Tkinter.Frame and populating the frame with whatever the widget will be then creating certain attributes/methods to be accessed later. My question is,...
12
by: Tom | last post by:
Hi all, I am a newbe to javascript so I could use your help. I checked the FAQs and searched google but I could not resolve this problem. My form is as follows: <form...
10
by: Data Guy | last post by:
In my approach to validation for widgets, i write javascript functions. At the end of the document, inside the form, i invoke the function as <FORM NAME="testit"> <INPUT TYPE="TEXT" VALUE="2"...
0
by: Alexandre Guimond | last post by:
Hi all. I'm creating a new widget class using Tkinter (class inherited form Tkinter.Frame). This class creates a bunch of other widgets inside it that can be "gridded" either horizontally or...
1
by: joe_doufu | last post by:
I'm creating a page with multiple "widgets", each with its own XMLHttpRequest object, so the user can play with the widgets in parallel. The widgets are enclosed in divs with class "widget" and a...
1
by: beenben | last post by:
function calculate(){ number= parseInt(numberof); var price=4; total=price*number; alert("Your total is $" + total); return true; };
6
by: shapper | last post by:
Hello, I am creating a form that includes a few JQuery scripts and TinyMCE Editor: http://www.27lamps.com/Beta/Form/Form.html I am having a few problems with my CSS: 1. Restyling the Select
2
by: Frowning Freezer | last post by:
How can the function below be rewritten to prioritize form fields instead of other objects with the same name? For example I want getele("title") to retrieve the form field named "title" instead...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.