So I have a client who is setting up a form that allows people to email their local state representative. Ideally, when they select their zip code from a drop down, what they'd like to happen is just below that, the name and address of that rep is displayed. Then below that is the letter and they can then submit. The drop down has to be duel purpose. I need it to know that depending on the zip code, a certain email will get the response. I know how to do that part because it's outlined in the Forms E-Book that was written. My question though is how do I tell the drop down to display the address of the representative just below it. Any ideas would be greatly appreciated. I'm kind of on a crunch to have this done before weeks end so you Chrono Gurus - help me out. Thanks
Or if anyone has done this with the chrono forms, I'd love to get a copy to work with.
Or if anyone has done this with the chrono forms, I'd love to get a copy to work with.
Hi prdg1,
I think you have two choices here - both require a little JavaScript.
Either you load the list of all the addresses into the Form HTML in hidden divs and un-hide the selected one.
Or you use Ajax to get the required address on selection. This requires a little PHP in one of the Extra Code boxes to get the address and return it plus the JavScript to run the Ajax call and handle the response.
The first option is much simpler and will work fine if the address list is short. If it's enormous that it might slow down the page load a lot.
Bob
I think you have two choices here - both require a little JavaScript.
Either you load the list of all the addresses into the Form HTML in hidden divs and un-hide the selected one.
Or you use Ajax to get the required address on selection. This requires a little PHP in one of the Extra Code boxes to get the address and return it plus the JavScript to run the Ajax call and handle the response.
The first option is much simpler and will work fine if the address list is short. If it's enormous that it might slow down the page load a lot.
Bob
Yeah I think the first option is going to be the easiest to do because they really want this to be pretty simple. Plus my list is pretty small - only about 20 zip codes. I'll do a bit more research to see how to write that. Not my strongest area but maybe there's something online. If you have recommendations on where to find this info on how to write it, let me know. Thanks again. Plus your book is great. I can't wait until you release one that's all advanced options. Love it.
Do you mind verifying that I did this right? In your ebook it said I could substitute the radio button for a drop down. My drop down is called "select3".
I entered the above in the "On Submit code - before sending email: (PHP code with tags)" box in the "Form Code" tab.
Normally I get the test emails pretty quick and nothing has happened so I just want to make sure this is correct. Seemed pretty simple but I'm not sure why it didn't send. I also made sure that in the "general tab" it's set to email. Also on the "setup emails" tab in the "to" field I inserted "email_to_use" without the quotes.
Also, if I don't want the admin to receive a copy of the email, it says to delete the first row
but it makes me think I need something there. Thanks a once again.
<?php
$select3 = JRequest::getString('select3', 'admin', 'post');
$emails = array (
'78002' => 'email@yahoo.com',
'78006' => 'email2@yahoo.com',
'78009' => 'email3@yahoo.com'
);
$email_to_use = $emails[$select3];
JRequest::setVar('email_to_use', $email_to_use);
?>
I entered the above in the "On Submit code - before sending email: (PHP code with tags)" box in the "Form Code" tab.
Normally I get the test emails pretty quick and nothing has happened so I just want to make sure this is correct. Seemed pretty simple but I'm not sure why it didn't send. I also made sure that in the "general tab" it's set to email. Also on the "setup emails" tab in the "to" field I inserted "email_to_use" without the quotes.
Also, if I don't want the admin to receive a copy of the email, it says to delete the first row
$select3 = JRequest::getString('select3', 'admin', 'post');
but it makes me think I need something there. Thanks a once again.
Hi prdg1,
What is the Form HTML you are using with this? It's not clear to me quite what is happening.
The 'admin' in the first line sets a default value - but for it to work you must also have 'admin' => [email]'emailx@yahoo.com[/email]', in the emails array (and you haven't got that entry).
Otherwise the code looks good provided that select3 is returning '78002', '78006', or '78009'.
Bob
What is the Form HTML you are using with this? It's not clear to me quite what is happening.
The 'admin' in the first line sets a default value - but for it to work you must also have 'admin' => [email]'emailx@yahoo.com[/email]', in the emails array (and you haven't got that entry).
Otherwise the code looks good provided that select3 is returning '78002', '78006', or '78009'.
Bob
UPDATE: Nevermind. I just caught I had the field wrong. It should have been select_3 instead of select3. I must REALLY be tired. I'm going to test that out and I'll get back to you.
UPDATE 2: That didn't seem to work. I'm following the instructions in the E-Book but it appears that everything I'm trying in the ebook isn't working. Hhhhmmm
Well I used the wizard so everything is properly there and I thought everything looked right. Forgive me, I'm on my IPhone so hopefully everything is coming across right. I really don't want the admin emailed a copy cause it might be too much email. So I assume I can delete that line. I also didn't do entries for all the zips because I just wanted to see if it would work first. Here is te HTML:
UPDATE 2: That didn't seem to work. I'm following the instructions in the E-Book but it appears that everything I'm trying in the ebook isn't working. Hhhhmmm
Well I used the wizard so everything is properly there and I thought everything looked right. Forgive me, I'm on my IPhone so hopefully everything is coming across right. I really don't want the admin emailed a copy cause it might be too much email. So I assume I can delete that line. I also didn't do entries for all the zips because I just wanted to see if it would work first. Here is te HTML:
<div class="form_item">
<div class="form_element cf_heading">
<h1 class="cf_text">Help Prevention Programs Now</h1>
</div>
<div class="clear"> </div>
</div>
<div class="form_item">
<div class="form_element cf_text"> <span class="cf_text">An ounce of prevention is worth a pound of cure. -- Benjamin Franklin</span> </div>
<div class="clear"> </div>
</div>
<div class="form_item">
<div class="form_element cf_text"> <span class="cf_text">If you have been following the news recently, you may have read about the pro-jected shortfall of over $18 Billion to the Texas budget for the next biennium. The Department of Family and Protective Services has proposed a budget that re-duces funding to their Prevention programs by 84%! Now is not (italicize) the time to stop prevention programs. Please help let our state legislators know that we need prevention programs. Just select your zip code below and generate a letter to your State Legislator. With your help, we can Keep San Antonio strong!</span> </div>
<div class="clear"> </div>
</div>
<div class="form_item">
<div class="form_element cf_dropdown">
<label class="cf_label">1. Search for your zip code</label>
<select class="cf_inputbox validate-selection" id="select_3" size="1" name="select_3">
<option value="">Choose Option</option>
<option value="78002">78002</option>
<option value="78006">78006</option>
<option value="78009">78009</option>
<option value="78015">78015</option>
<option value="78023">78023</option>
<option value="78038">78038</option>
<option value="78052">78052</option>
<option value="78064">78064</option>
<option value="78069">78069</option>
<option value="78073">78073</option>
<option value="78101">78101</option>
<option value="78108">78108</option>
<option value="78109">78109</option>
<option value="78112">78112</option>
<option value="78121">78121</option>
<option value="78124">78124</option>
<option value="78148">78148</option>
<option value="78151">78151</option>
<option value="78152">78152</option>
<option value="78154">78154</option>
<option value="78201">78201</option>
<option value="78202">78202</option>
<option value="78203">78203</option>
<option value="78204">78204</option>
<option value="78205">78205</option>
<option value="78207">78207</option>
<option value="78208">78208</option>
<option value="78209">78209</option>
<option value="78210">78210</option>
<option value="78211">78211</option>
<option value="78212">78212</option>
<option value="78213">78213</option>
<option value="78214">78214</option>
<option value="78215">78215</option>
<option value="78216">78216</option>
<option value="78217">78217</option>
<option value="78218">78218</option>
<option value="78219">78219</option>
<option value="78220">78220</option>
<option value="78221">78221</option>
<option value="78222">78222</option>
<option value="78223">78223</option>
<option value="78224">78224</option>
<option value="78225">78225</option>
<option value="78226">78226</option>
<option value="78227">78227</option>
<option value="78228">78228</option>
<option value="78229">78229</option>
<option value="78230">78230</option>
<option value="78231">78231</option>
<option value="78232">78232</option>
<option value="78233">78233</option>
<option value="78234">78234</option>
<option value="78235">78235</option>
<option value="78236">78236</option>
<option value="78237">78237</option>
<option value="78238">78238</option>
<option value="78239">78239</option>
<option value="78240">78240</option>
<option value="78242">78242</option>
<option value="78244">78244</option>
<option value="78245">78245</option>
<option value="78247">78247</option>
<option value="78248">78248</option>
<option value="78249">78249</option>
<option value="78250">78250</option>
<option value="78251">78251</option>
<option value="78252">78252</option>
<option value="78253">78253</option>
<option value="78254">78254</option>
<option value="78255">78255</option>
<option value="78256">78256</option>
<option value="78257">78257</option>
<option value="78258">78258</option>
<option value="78259">78259</option>
<option value="78260">78260</option>
<option value="78261">78261</option>
<option value="78263">78263</option>
<option value="78264">78264</option>
<option value="78266">78266</option>
</select>
</div>
<div class="clear"> </div>
</div>
<div class="form_item">
<div class="form_element cf_textarea">
<label class="cf_label">2. Write Your Letter</label>
<textarea class="cf_inputbox" rows="26" id="text_8" cols="60" name="text_8"></textarea>
</div>
<div class="clear"> </div>
</div>
<div class="form_item">
<div class="form_element cf_textbox">
<label class="cf_label">3. Enter Your Full Name</label>
<input class="cf_inputbox required" maxlength="150" size="30" id="text_9" name="text_9" type="text" />
</div>
<div class="clear"> </div>
</div>
<div class="form_item">
<div class="form_element cf_text"> <span class="cf_text">(This will be used for your electronic signature)</span> </div>
<div class="clear"> </div>
</div>
<div class="form_item">
<div class="form_element cf_textbox">
<label class="cf_label">4. Enter Your Email Address</label>
<input class="cf_inputbox required validate-email" maxlength="150" size="30" id="text_12" name="text_12" type="text" />
</div>
<div class="clear"> </div>
</div>
<div class="form_item">
<div class="form_element cf_text"> <span class="cf_text">(This is needed in order to generate the automated email.)</span> </div>
<div class="clear"> </div>
</div>
<div class="form_item">
<div class="form_element cf_button">
<input value="Submit" type="submit" />
</div>
<div class="clear"> </div>
</div>
This topic is locked and no more replies can be posted.