Author Topic: JQuery  (Read 2677 times)

ober

  • Ashton Shagger
  • Ass Wipe
  • Posts: 14310
  • Karma: +73/-790
  • mini-ober is taking over
    • Windy Hill Web Solutions
JQuery
« on: March 04, 2012, 03:09:11 PM »
This isn't working:

Code: [Select]
function apply_promo()
{
var pcode = $("#promo").val();       
    alert(pcode);
    location.href = "index.php?req=quote&applypromo="+pcode;
}

pcode is blank every time.  WTF?

ober

  • Ashton Shagger
  • Ass Wipe
  • Posts: 14310
  • Karma: +73/-790
  • mini-ober is taking over
    • Windy Hill Web Solutions
Re: JQuery
« Reply #1 on: March 04, 2012, 03:14:35 PM »
Fuck me... it's like all I need to do is post something on here and then it jumps out at me.  I had a div and text box with the same id.  Grrr...

Mike

  • Jackass In Charge
  • Posts: 11257
  • Karma: +168/-32
  • Ex Asshole - a better and more caring person.
Re: JQuery
« Reply #2 on: March 04, 2012, 03:50:58 PM »
Hate that mistake (the dup id not the post and realize mistake)

-KEN-

  • Some Other Mofo
  • Jackass In Charge
  • Posts: 1001
  • Karma: +75/-100
Re: JQuery
« Reply #3 on: March 06, 2012, 02:44:04 PM »
this might be silly, but why not just use a submit form for that?

ober

  • Ashton Shagger
  • Ass Wipe
  • Posts: 14310
  • Karma: +73/-790
  • mini-ober is taking over
    • Windy Hill Web Solutions
Re: JQuery
« Reply #4 on: March 06, 2012, 02:46:34 PM »
Because I want them to see the discount before they enter the checkout process and I don't want to submit the whole form?

-KEN-

  • Some Other Mofo
  • Jackass In Charge
  • Posts: 1001
  • Karma: +75/-100
Re: JQuery
« Reply #5 on: March 06, 2012, 09:45:22 PM »
Just asking a question since there was no context, snarko.

Mike

  • Jackass In Charge
  • Posts: 11257
  • Karma: +168/-32
  • Ex Asshole - a better and more caring person.
Re: JQuery
« Reply #6 on: March 06, 2012, 09:46:57 PM »
Of course, I'd probably still submit the form rather than use window.location but that is me.

ober

  • Ashton Shagger
  • Ass Wipe
  • Posts: 14310
  • Karma: +73/-790
  • mini-ober is taking over
    • Windy Hill Web Solutions
Re: JQuery
« Reply #7 on: March 06, 2012, 11:04:47 PM »
Just asking a question since there was no context, snarko.
Sorry, wasn't trying to be snarky. 

Of course, I'd probably still submit the form rather than use window.location but that is me.
I have no issues with location.href.

Mike

  • Jackass In Charge
  • Posts: 11257
  • Karma: +168/-32
  • Ex Asshole - a better and more caring person.
Re: JQuery
« Reply #8 on: March 06, 2012, 11:12:04 PM »
It is mostly personal preference.  If the page has a form I'd rather use the native submit functionality (even if I'm triggering it in JS).

ober

  • Ashton Shagger
  • Ass Wipe
  • Posts: 14310
  • Karma: +73/-790
  • mini-ober is taking over
    • Windy Hill Web Solutions
Re: JQuery
« Reply #9 on: March 07, 2012, 12:17:49 AM »
Agreed.  But the noted action just updates a single part of a shopping cart and is not intended to move the user further into the process.