Solved

<input type="button"> fails to pass name="" and value=""

Posted on 2003-11-18
8
544 Views
Last Modified: 2013-12-03
I am writing a shopping cart application that uses both select boxes and buttons on the same page to submit variables and values to a Perl script.  I am using javascript to submit information to the script.  I have created a script that I have confidence accurately reads what is being passed thru the browser to the application and find that the select boxes work fine but the buttons fail to pass their information.  

Here are sample select and button tags.

<select name="choice1" onChange="javascript:document.workorder.submit()">
<option value="choose" selected>Choose Service:
<option value="men">Men's
<option value="women">Women's
<option value="summarize">Review Order
<option value="checkout">Check Out
</select>

<input type="button" name="b1" value="Clear All" onclick="javascript:document.workorder.submit()"><input type="button" name="b2" value="Subtotal" onclick="javascript:document.workorder.submit()"><input type="button" name="b3" value="Add To Order" onclick="javascript:document.workorder.submit()"><input type="button" name="b4" value="Check Out" onclick="javascript:document.workorder.submit()">

I find that the buttons do submit all other information to the Perl script,  just not their name-value pair.

Mercy!

0
Comment
Question by:Shearer-Services
8 Comments
 
LVL 5

Expert Comment

by:DesertWarrior
ID: 9771613
you should create a function to separate each action...

<input type="button" name="b1" value="Clear All" onclick="CallPage(1)"><input type="button" name="b2" value="Subtotal" onclick="CallPage(2)"><input type="button" name="b3" value="Add To Order" onclickonclick="CallPage(3)"><input type="button" name="b4" value="Check Out" onclick="CallPage(4)">


function CallPage(action)
{
if (action == 1) //meaning the user clicked on Clear All
{
      document.workorder.action = NameOfThePageToCall.asp?action=1
      document.workorder.submit()
}
if (action == 2) //meaning the user clicked on SubTotal
{
      document.workorder.action = NameOfThePageToCall.asp?action=2
      document.workorder.submit()
}
if (action == 3) //meaning the user clicked on Add To Order
{
      document.workorder.action = NameOfThePageToCall.asp?action=3
      document.workorder.submit()
}
if (action == 4) //meaning the user clicked on CheckOut
{
      document.workorder.action = NameOfThePageToCall.asp?action=4
      document.workorder.submit()
}
}

and then on the Page that receives all the information you do a Request.Querystring("action") to know the value and to be able to manage what do to...
0
 
LVL 16

Expert Comment

by:jaysolomon
ID: 9771651
>>>onclickonclick="CallPage(3)"><

should be (and probaly a typo) onclick="CallPage(3)"
0
 
LVL 5

Expert Comment

by:DesertWarrior
ID: 9772095
yeah
i'm a ctrl C, ctrl V maniac
thanks :)
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:Shearer-Services
ID: 9772471
So if I answer my own question, do I get the points?  LOL

I pulled the code out of the script to remove any other conflicts that might cause the problem and created a new page.  By changing the input tag type to submit and removing the onclick="java*" I can now pass name-value pairs for all controls and related variables.   The changed portion of the code looks like this:

<input type="submit" name="b1" value="Clear All" >
<input type="submit" name="b2" value="Subtotal" >
<input type="submit" name="b3" value="Add To Order">
<input type="submit" name="b4" value="Check Out">

Thanks for the help.
0
 
LVL 5

Expert Comment

by:DesertWarrior
ID: 9773250
:/
this is a weird way of programming
anyways,
u do as u wish
0
 
LVL 35

Expert Comment

by:YZlat
ID: 9778997
are your <select> and buttons inside the <form> tags?
0
 
LVL 2

Accepted Solution

by:
Lunchy earned 0 total points
ID: 9800063
PAQed, with points refunded (250)

Lunchy
Friendly Neighbourhood Community Support Admin
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are two main kinds of selectors in CSS: One is base selector like h1, h2, body, table or any existing HTML tags.  For instance, the following rule sets all paragraphs (<p> elements) to red: (CODE) CSS also allows us to define our own custom …
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question