Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-05-30 00:05:02

roadkillu
New Member
Registered: 2007-05-29
Posts: 5

Javascript/PHP combo in textpattern

OK, I’m more of a business guy than a programmer. But I’ve been messing around with textpattern the last few days and it’s actually starting to come together for me! (somewhat!).

Here’s my issue:

I have a piece of javascript on a standard html page that generates a form where users can imput a telephone and the form (using a .php function thing) then sends an e-mail to the owners of that page’s e-mail. Gosh, I hope that made sense.

You can see the “call me” button here: (hope I can post a link)

http://www.notaryone.net/hillsboro-or-notary.html

(please don’t fill it out, trust me it works, I don’t want Chris hating on me)

So, I’m going to redo our entire site in Textpattern, and I’d like to have this same function work on the new site. Even better, I’d like to replace manually inserting the cell phone number with a variable, if possible.

I just can’t seem to get the darn thing to work correctly. Should I create a form with the javascript and then call the form? (I know in theory how that would look, but I don’t know how to do it).

Here’s the html I use on the static page:

<a href =“javascript: var e = window.open(‘call_me.php?phone_num=5033848576’,‘chatWindow’,
‘width=400,height=200,resizable=0,scrollbars=no,menubar=no,status=no’);”“
onMouseOver=“MM_swapImage(‘call_me’,’‘,‘images/call_meh.jpg’,1)” onMouseOut=“MM_swapImgRestore()”>

<img src=” http://www.notaryone.net/images/call_me.jpg” alt=“Request a call back” name=“call_me” border=“0” id=“call_me”></a>

I’ve uploaded the “call_me.php” file to my textpattern root.

Sorry so long, I don’t know how the community is here, taking a shot at a long post from a newby. Thanks!

Offline

#2 2007-05-30 00:47:28

roadkillu
New Member
Registered: 2007-05-29
Posts: 5

Re: Javascript/PHP combo in textpattern

Free cookies to anyone who can help me out this! (ok, so they won’t be real cookies…unless I mail them. I could do that…)

Offline

#3 2007-05-30 00:52:03

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: Javascript/PHP combo in textpattern

You can either put it straight into your page or put it in a form (a good idea if you want to use it on multiple pages). Pages and forms are just (X)HTML, that are parsed for Textpattern’s tags before being sent to the browser.

Offline

#4 2007-05-30 01:55:49

roadkillu
New Member
Registered: 2007-05-29
Posts: 5

Re: Javascript/PHP combo in textpattern

OMG. That’s awesome! Got it working in 30 seconds. Thanks Mary!

Offline

#5 2007-05-30 01:58:56

roadkillu
New Member
Registered: 2007-05-29
Posts: 5

Re: Javascript/PHP combo in textpattern

OK, one more thing, I created a form containing this code:

<a href =“javascript: var e = window.open(‘call_me.php?phone_num=5033848576’,‘chatWindow’,
‘width=400,height=200,resizable=0,scrollbars=no,menubar=no,status=no’);”“
onMouseOver=“MM_swapImage(‘call_me’,’‘,‘images/call_meh.jpg’,1)” onMouseOut=“MM_swapImgRestore()”>

Is there a way to replace the 10 digit cellphone number with the cellphone number that I define in the article as a custom field?

Offline

#6 2007-05-30 02:13:09

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: Javascript/PHP combo in textpattern

Sure. :) Where your custom field is named “cellphone”, you’d put something like the following in your article form (called by the article tag):

<txp:if_custom_field name="cellphone"><a href"=javascript: var e = window.open('call_me.php?phone_num=<txp:custom_field name="cellphone" />', 'chatWindow', 'width = 400, height = 200, resizable = 0, scrollbars = no, menubar = no, status = no');" onmouseover="MM_swapImage('call_me', '', 'images/call_meh.jpg', 1)" onmouseout="MM_swapImgRestore();"></txp:if_custom_field>

Offline

#7 2007-05-30 03:06:38

roadkillu
New Member
Registered: 2007-05-29
Posts: 5

Re: Javascript/PHP combo in textpattern

Wow. This is great. So, I ended up calling the variable (is that the right language?) in a seperate form with just the javascript. And then I used output_form to show that in the article form. Cool beans. Man, I feel nerdy, this is great. Thanks Mary.

Offline

#8 2007-05-30 10:52:31

Dragondz
Moderator
From: Algérie
Registered: 2005-06-12
Posts: 1,538
Website GitHub Twitter

Re: Javascript/PHP combo in textpattern

Dont forget de send her cookies ;)

Offline

Board footer

Powered by FluxBB