Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #10223 > unrolled thread

determine which submit input is clicked, get syntax error

Started by"css-discuss.org" <janis.rough@gmail.com>
First post2012-01-13 17:32 -0800
Last post2012-01-15 15:01 -0800
Articles 7 — 3 participants

Back to article view | Back to comp.lang.javascript


Contents

  determine which submit input is clicked, get syntax error "css-discuss.org" <janis.rough@gmail.com> - 2012-01-13 17:32 -0800
    Re: determine which submit input is clicked, get syntax error "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2012-01-14 09:27 +0200
      Re: determine which submit input is clicked, get syntax error JRough <janis.rough@gmail.com> - 2012-01-15 11:27 -0800
        Re: determine which submit input is clicked, get syntax error "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2012-01-15 22:35 +0200
          Re: determine which submit input is clicked, get syntax error JRough <janis.rough@gmail.com> - 2012-01-15 14:13 -0800
          Re: determine which submit input is clicked, get syntax error JRough <janis.rough@gmail.com> - 2012-01-15 14:17 -0800
          Re: determine which submit input is clicked, get syntax error JRough <janis.rough@gmail.com> - 2012-01-15 15:01 -0800

#10223 — determine which submit input is clicked, get syntax error

From"css-discuss.org" <janis.rough@gmail.com>
Date2012-01-13 17:32 -0800
Subjectdetermine which submit input is clicked, get syntax error
Message-ID<055f38d5-d99f-48ca-a14b-09867f95e9f4@iu7g2000pbc.googlegroups.com>
I have a question about the submit inputs.  There are two filtered
submit inputs that are independent of each other.
I want to capture which one the user clicked.  I get a syntax error on
the asterisks.
Firebug says "illegal character "  at the end of the else if line.
I think it may be because the
onclicks submit buttons are outside the javascript or else the onclick
needs to be a js function?
I tried putting javascript tags around the form but I got the same
exact error.
The global var btnClicked needs to pick up the value of which submit
button was clicked.
Then the clkButton function return value should be passed to the
getConfigURL function.
It looks like it should work and just needs some clarity on the above.
Thanks, JR
<form>-----------------------------
<span id= "searchOrderNumber">
Order Number: <input type="text" id="orderNumber" name="orderNumber"
size="20" value="" />
                             <input  id="filterSearch"  type="submit"
value="Search"  onclick="btnClicked=this" /></span>


<ul>
<li>Start Date: <input type="text" id="startDate" name="startDate" /
><input type="hidden" id="xmlStartDate" name="xmlStartDate" /></li>
<li>End Date: <input type="text" id="endDate" name="endDate" /><input
type="hidden" id="xmlEndDate" name="xmlEndDate" /></li>
<li>EmpNo: <input type="text" id="EmpNo" name="EmpNo" size="4"
value="" /></li>
<li><input id="filterSubmit" type="submit" value="Submit"
onclick="btnClicked=this" /></li>
</ul>
</form>----------------------------------

var btnClicked;// global var to see which filter selected, see input
form

	function clkButton() {
             	var submit;
		if(btnClicked.value== 'Submit' ) {
  		 	submit = 'submitFilter' ;
		}else if (btnClicked.value=='Search') { ​  ******stops here before
it gets passed to next function
			submit = 'submitSearch' ;
		}
	return submit;
             }

	function getConfigURL(submitType,xmlStartDate, xmlEndDate) {
                        if(submitType=="submitFilter") {   //
clickHandler
			var plant = YAHOO.util.Dom.get("userPlant").value;
	           		var configURL = sent parameters in url to databasexxxxx
			.........................
                         }else if(submitType=="submitSearch"){ //
clickHandler2
	           		var configURL = sent parameters in url to
databasexxxxxxxx
			var orderNumber = YAHOO.util.Dom.get("orderNumber").value;
		}
                	....................................

[toc] | [next] | [standalone]


#10224

From"Jukka K. Korpela" <jkorpela@cs.tut.fi>
Date2012-01-14 09:27 +0200
Message-ID<jerap3$u9p$1@dont-email.me>
In reply to#10223
2012-01-14 3:32, css-discuss.org wrote:

> I have a question about the submit inputs.

How about posting a URL? It's rather awkward to try to debug code that 
has been munged by your Usenet posting software (lines broken etc.) and 
that does not constitute a full document.

> I get a syntax error on
> the asterisks.
> Firebug says "illegal character "  at the end of the else if line.

How about fixing the error then?

> 		}else if (btnClicked.value=='Search') { ​  ******stops here before

You don't think that proper JavaScript code, do you?

P.S. In your sender information on Usenet, it's not wise to use a fake 
name that coincides with the name of a reputable discussion list.

-- 
Yucca, http://www.cs.tut.fi/~jkorpela/

[toc] | [prev] | [next] | [standalone]


#10265

FromJRough <janis.rough@gmail.com>
Date2012-01-15 11:27 -0800
Message-ID<5f0b2f5c-356b-4669-8bc1-637e15fcb5f6@g4g2000pbi.googlegroups.com>
In reply to#10224
On Jan 13, 11:27 pm, "Jukka K. Korpela" <jkorp...@cs.tut.fi> wrote:
> 2012-01-14 3:32, css-discuss.org wrote:
> > I have a question about the submit inputs.
>
> How about posting a URL? It's rather awkward to try to debug code that
> has been munged by your Usenet posting software (lines broken etc.) and
> that does not constitute a full document.
>
> > I get a syntax error on
> > the asterisks.
> > Firebug says "illegal character "  at the end of the else if line.
>
> How about fixing the error then?
>
> >            }else if (btnClicked.value=='Search') { ​  ******stops here before
>
> You don't think that proper JavaScript code, do you?
>
> P.S. In your sender information on Usenet, it's not wise to use a fake
> name that coincides with the name of a reputable discussion list.
>
> --
> Yucca,http://www.cs.tut.fi/~jkorpela/

I fixed the hidden name issue, I had posted to a css group and somehow
copied that group email adrs onto the javascript group in google
groups? It was not intentional.    The data is XML data delivered from
SAP which can't be recreated. In any case, I have a web  server at
home so I put an example on janisrough.dyndns.biz/tracking.html.

I  added a search box for the order number field, a single search for
one order on one row, it is the first "search" button.  The "submit"
button filter was already there that allows filtering on all the
fields returned in a table of data with nice drop downs etc from YUI
and I could not recreate that here because it is all customized
functions but you get the idea.

I want the user to be able to select either filter button,  they are
mutually exclusive filters.  I had it working but I noticed the
previous "orderNumber" had to be cleared out of the field for the 2nd
submit filter to work and vice versa so the user could do as many
searches on either filter as necessary.
The process of the page:
The  clickhandler2() function was added to capture the click event for
the new  "orderNumber" search filter.  The configURL sends the URL to
SAP and loads the XML data and creates a URL to be passed to SAP.  I
added the if{} else{} to this configURL() function and the submitType
parameter passed to it to determine which filter was submitted.

My idea on how to clear out the inputted data to start a new search
was to add the clkButton event handler to check for which search
button was clicked and pass it to the configURL(submitType) function
instead of passing it to each clickHandler so the old data doesn't get
in the way.  It just checks which filter was submitted each time.
This is what doesn't appear to be working and I think there is a
simple reason why that I need some explanation on.  I added the global
var btnClicked, see the related form "btnClicked" This clkButton event
is not really an event it is just HTML flag.  Is that right?  It
doesn't need to be enclosed in <script type=javascript/text> tags?  It
seems like this is where the error is but I can't tell for sure so I
am wondering if what I did is right? NOtice in the form that it isn't
a click event it just picks up the submit click from the HTML then the
function passes it to the configURL.
Thanks very much,
Jan

[toc] | [prev] | [next] | [standalone]


#10270

From"Jukka K. Korpela" <jkorpela@cs.tut.fi>
Date2012-01-15 22:35 +0200
Message-ID<jevdaf$qvh$1@dont-email.me>
In reply to#10265
2012-01-15 21:27, JRough wrote:

> I put an example on janisrough.dyndns.biz/tracking.html.

Sorry, it does make much sense. What is it supposed to submit to, and 
why is the JavaScript code as text content there?

It's not even obvious why you have two submit buttons in a <form> 
element that is not closed anywhere. Why not two separate forms, each 
with fields and submit buttons of their own? Then you would not need to 
worry about detecting client-side which button was clicked on.

-- 
Yucca, http://www.cs.tut.fi/~jkorpela/

[toc] | [prev] | [next] | [standalone]


#10272

FromJRough <janis.rough@gmail.com>
Date2012-01-15 14:13 -0800
Message-ID<cdc632d4-b9be-4b0d-8b0d-9d6ed24f5534@x4g2000pbq.googlegroups.com>
In reply to#10270
On Jan 15, 12:35 pm, "Jukka K. Korpela" <jkorp...@cs.tut.fi> wrote:
> 2012-01-15 21:27, JRough wrote:
> > I put an example on janisrough.dyndns.biz/tracking.html.
>
> Sorry, it does make much sense. What is it supposed to submit to, and
> why is the JavaScript code as text content there?
>
> It's not even obvious why you have two submit buttons in a <form>
> element that is not closed anywhere. Why not two separate forms, each
> with fields and submit buttons of their own? Then you would not need to
> worry about detecting client-side which button was clicked on.
>
> --
> Yucca,http://www.cs.tut.fi/~jkorpela/

That is a good question but can't 100% explain everything on the real
page except that YUI loader picks up the values in the inputs and
strings them together in the configURL and then sends them via the
illuminator string in configURL to SAP via the key and some loader
functions.  There is one string for each filter.  There is actually no
form in the original page that works on the one search.  I just added
the form to try to understand what is going on.  I think YUI is using
event functions.  So are you saying this btnClicked() will not work?

var configURL = "/XXXX/Illuminator?Transaction=" +
XXX.config.GLOBAL_DIR + "/Message%20Queue/
GetMessageQueue&Server=XacuteConnector&Mode=Query&RowCount=99999&OutputParameter=outputXML&Content-
Type=text/xml&key=message";
thanks,

[toc] | [prev] | [next] | [standalone]


#10273

FromJRough <janis.rough@gmail.com>
Date2012-01-15 14:17 -0800
Message-ID<65167a7b-845c-43dc-9d7f-d924d9fa8b47@b4g2000pbi.googlegroups.com>
In reply to#10270
On Jan 15, 12:35 pm, "Jukka K. Korpela" <jkorp...@cs.tut.fi> wrote:
> 2012-01-15 21:27, JRough wrote:
> > I put an example on janisrough.dyndns.biz/tracking.html.
>
> Sorry, it does make much sense. What is it supposed to submit to, and
> why is the JavaScript code as text content there?
>
> It's not even obvious why you have two submit buttons in a <form>
> element that is not closed anywhere. Why not two separate forms, each
> with fields and submit buttons of their own? Then you would not need to
> worry about detecting client-side which button was clicked on.
>
> --
> Yucca,http://www.cs.tut.fi/~jkorpela/

About the Javascript code as text content, I thought it wasn't a real
event but I guess the this keyword is a Javascript keyword.  Ok maybe
I am making it too difficult.  If I could add two forms then I could
test for which form was clicked but then why does it work with no
form?  I guess that must be the answer,but I was trying to do it the
way it was done without a form not knowing why there is no form
thinking it has something to do with YUI I don't understand.  Thanks
for your input,

[toc] | [prev] | [next] | [standalone]


#10275

FromJRough <janis.rough@gmail.com>
Date2012-01-15 15:01 -0800
Message-ID<033d4753-b55a-47dc-922e-e447e11987f5@n7g2000pbd.googlegroups.com>
In reply to#10270
On Jan 15, 12:35 pm, "Jukka K. Korpela" <jkorp...@cs.tut.fi> wrote:
> 2012-01-15 21:27, JRough wrote:
> > I put an example on janisrough.dyndns.biz/tracking.html.
>
> Sorry, it does make much sense. What is it supposed to submit to, and
> why is the JavaScript code as text content there?
>
> It's not even obvious why you have two submit buttons in a <form>
> element that is not closed anywhere. Why not two separate forms, each
> with fields and submit buttons of their own? Then you would not need to
> worry about detecting client-side which button was clicked on.
>
> --
> Yucca,http://www.cs.tut.fi/~jkorpela/

Okay I created two forms with separate id's around the two separate
searches.  It appears that the string to the server is a GET post.  I
do get the value of which button was submitted? tnx,

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.javascript


csiph-web