simplemodal contact form passing HTML variables to JAVASCRIPT and to PHP -
i'm new javascript, experience in php, working html , css styles. downloaded simplemodal contact form eric martin's website looks nice. able implement modal pop-up contact form in testing website @ location:
http://www.patagonia-tours.net/tours/patagonia.htm
in page have listed 3 different tours, , i'd visitor enquiry/ask question on every of them, , purpose added modal form.
i need solve 2 things:
number 1
to pass variable html javascript tour name, using variable title of contact form. figured out variable located in contact.js file , named 'title'.
this html code 3 buttons calling modal form:
<div id='contact-form'> <input type='button' name='contact' value='ask question / book' class='tour-button button-white' title='tour: el calafate / ushuaia / torres del paine'> </div> <div id='contact-form'> <input type='button' name='contact' value='ask question / book' class='tour-button button-white' title='tour: ushuaia / australis / paine / calafate'> </div> <div id='contact-form'> <input type='button' name='contact' value='ask question / book' class='tour-button button-white' title="tour: ushuaia / puerto madryn">
the need pass value of title attribute in html 'title' variable in javascript.
number 2
i need pass same variable php script (contact.php), can use subject in email knowing tour visitor interested in, , don't how (i did try variants without success).
as mentioned in comment cannot have duplicate id values or else javascript not know 1 grab (as expects one, stop @ first);
if change id's classes can this:
<div id='contact-form'> <input type='button' name='contact' value='ask question / book' class='tour-button contact button-white' title="tour: ushuaia / puerto madryn"> </div> var buttons = document.getelementsbyclassname('tour-button'); for( var = 0, l = buttons.length; < l; i++ ) { buttons[i].addeventlistener('click', function() { alert( this.title ); }, false); }
as number 2, should ask in new question code have tied.
edit:
assuming have variable defined somewhere else var title = '';
or var title;
change above code this:
var buttons = document.getelementsbyclassname('tour-button'); for( var = 0, l = buttons.length; < l; i++ ) { buttons[i].addeventlistener('click', function() { title = this.title; }, false); }
that assigns variable 'title' value of title in last button clicked. if trying changes on click action suggest put code in event handler button clicks.
Comments
Post a Comment