vendredi 3 avril 2015

pass values by clicking a buttons on page1.php to textarea on page2.php

I have a contact form with a textarea and a prewritten text in it. I have several buttons on another page (e.g. one is for "finance", another one for "funds" etc.). now I want the said buttons to pass their own value to the textarea in the sentence.


so far I managed to make the buttons under the textarea on the same page and to pass the whole sentence with one word difference to the textarea.


how can I manage to get the buttons on another page and how can I pass only one word in the existing sentence?


Here's my Fiddle:


Fiddle


Here's my HTML & CSS



<div id="content" class="wrapperleer">
<div id="stylized" class="myform">

<form id="form1" id="form1" action="../wp-content/themes/bare-responsive2/mail.php" method="POST">

<label>Name
</label>
<input type="text" name="username" required="required">
<label>Email
</label>
<input type="text" name="email" required="required">

<label for="newsletter">Newsletter</label>
<div id="check"><input type="checkbox" name="newsletter" value="newsletter"></div>


<label>Message
</label>
<textarea name="message" rows="6" cols="25">Hi Im interested in ... Please contact me about the next session. </textarea><br />

<button type="submit" value="Send" style="margin-top:15px;">Send</button>
<div class="spacer"></div>
</form>

<form action="input_button.htm">
<p>
<input type="button" name="Text 1" value="Text1"
onclick="form1.message.value='Hi Im interested in &quot;Finaces&quot;. Please contact me about the next session.'">
<input type="button" name="Text 2" value="Text2"
onclick="form1.message.value='Hi Im interested in &quot;Savings&quot;. Please contact me about the next session.'">
<input type="button" name="Text 3" value="Text3"
onclick="form1.message.value='Hi Im interested in &quot;Funds&quot;. Please contact me about the next session.'">
</p>
</form>

</div> <!-- end of form class -->
</div>




.spacer{clear:both; height:1px;}
/* ----------- My Form ----------- */

.myform{

width:600px;
padding:14px;
}
/* ----------- stylized ----------- */
#stylized{
background: rgba(255, 255, 255, 0.7);
border: 2px solid #fff;

}
#stylized h1 {
font-size:14px;
font-weight:bold;
margin-bottom:8px;
}
#stylized p{
font-size:11px;
color:#666666;
margin-bottom:20px;
border-bottom:solid 1px #b7ddf2;
padding-bottom:10px;
}
#stylized label{
display:block;
font-weight:bold;
text-align:right;
width:140px;
float:left;
}
#stylized .small{
color:#666666;
display:block;
font-size:11px;
font-weight:normal;
text-align:right;
width:140px;
}

#stylized input{
float:left;
font-size:12px;
padding:4px 2px;
border:solid 1px #aacfe4;
width:400px;
margin:2px 0 20px 10px;
}
#check{width:400px; display: inline-block;}
#check input{width:auto; }

#stylized textarea{
float:left;
font-size:12px;
padding:4px 2px;
border:solid 1px #aacfe4;
width:400px;
margin:2px 0 20px 10px;
}
#stylized button{
clear:both;
margin-left:160px;
width:125px;
height:31px;
background:#444;
text-align:center;
line-height:31px;
color:#FFFFFF;
font-size:11px;
font-weight:bold;
}

Aucun commentaire:

Enregistrer un commentaire