Solved

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

Posted on 2003-11-18
8
545 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

 

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Suggested Courses

617 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