men der henter den jo først ved tryk på en knap ?
$("#vedr").click(function(){
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>ajax test</title> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> <style type="text/css"> </style> <script type="text/javascript"> $(document).ready(function(){ $(".vedr").click(function(){ $.ajax({ type: "GET", url: "content.html", success: function(data){ $("#content").html(data); } }); }); }); </script> </head> <body> <form action="#" method="post" class="message"> Tilbud: <input type="radio" class="vedr" name="vedr" value="Tilbud"> Support: <input type="radio" class="vedr" name="vedr" value="Support"> <div id="content"></div> </form> </body> </html>
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>test</title> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> <style type="text/css"> </style> <script type="text/javascript"> $(document).ready(function(){ $(".vedr").click(function(){ // http://stackoverflow.com/questions/596351/how-can-i-get-which-radio-is-selected-via-jquery var params = "id=" + $('input[name=vedr]:checked', '#testfrm').val() // alert(params); $.ajax({ type: "GET", data: params, url: "content.php", success: function(data){ $("#content").html(data); } }); }); }); </script> </head> <body> <form action="#" method="post" class="message" id="testfrm"> Tilbud: <input type="radio" class="vedr" name="vedr" value="Tilbud"> Support: <input type="radio" class="vedr" name="vedr" value="Support"> <div id="content"></div> </form> </body> </html>
<?php $id=$_GET['id']; switch($id){ case "Tilbud": $str ='<input type="text" value="Name" > <input type="text" value="Email"> <input type="text" value="Subject"> <input type="submit" value="Send">'; break; case "Support": $str ='<input type="text" value="Name" > <input type="text" value="Email"> <input type="text" value="Subject"> <textarea></textarea> <input type="submit" value="Send">'; break; default: $str = '<input type="submit" value="Send">'; break; } echo $str; ?>
<html> <head> <title>Leg med AJAX</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("#vedr").click(function(){ $.ajax({ type: "GET", url: "content.html", success: function(data){ $("#content").html(data); } }); }); }); </script> </head> <body> <form action="#" method="post" class="message"> Tilbud: <input type="radio" name="vedr" onclick="this.form.submit();" value="Tilbud"> Support: <input type="radio" name="vedr" value="Support"> <div id="content"> </div> </form> </body> </html>
<input type="text" value="Name" onFocus="this.select();" onMouseOut="javascript:return false;"/> <input type="text" value="Email" onFocus="this.select();" onMouseOut="javascript:return false;"/> <input type="text" value="Subject" onFocus="this.select();" onMouseOut="javascript:return false;"/> <textarea></textarea> <input type="submit" value="Send"/>
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>*****.net - Din vej til en billig hjemmeside</title> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> <link rel="stylesheet" href="css/style.css" type="text/css"> <script type="text/javascript"> $(document).ready(function(){ $(".vedr").click(function(){ // http://stackoverflow.com/questions/596351/how-can-i-get-which-radio-is-selected-via-jquery var params = "id=" + $('input[name=vedr]:checked', '#kontakt').val() // alert(params); $.ajax({ type: "GET", data: params, url: "content.php", success: function(data){ $("#content").html(data); } }); }); }); </script> </head> <body> <div id="header"> <div> <div class="logo"> <a href="index.html">Ringvig.net</a> </div> <ul id="navigation"> <li> <a href="index.html">Forside</a> </li> <li> <a href="tilbyder.html">Tilbyder</a> </li> <li> <a href="pris.html">Priser</a> </li> <li> <a href="referencer.html">Referencer</a> </li> <li class="active"> <a href="kontakt.php">Kontakt</a> </li> </ul> </div> </div> <div id="contents"> <div class="section"> <h1><b><u>Kontakt</u></b></h1> <p> Hvad handler din henvendelse om? <form action="#" method="post" class="message" id="kontakt"> Tilbud: <input type="radio" class="vedr" name="vedr" value="Tilbud"> Support: <input type="radio" class="vedr" name="vedr" value="Support"> <div id="content"></div> </form> <?php if(isset($_POST['send'])) { if (empty($_POST['navn'])) { echo"Du skal indtaste dit navn"; } elseif (empty($_POST['email'])) { echo "Du skal indtaste din e-mail"; } elseif (empty($_POST['besked'])) { echo "Du skal indtaste en besked"; } else { $franavn = $_POST['navn']; $framail = $_POST['mail']; $emne= $_POST['vedr']; $besked = $_POST['tekst']; $valg = $_POST['valg']; $valget = "Ang: $valg"; $fejl = $_POST['fejl']; $fejlen = "Fejlen: $fejl<br>"; $indhold = "Vedr: $emne<br>$fejlen $valget Navn: $franavn<br>Mail: $framail<br><br>Beskeden: $besked"; $sendtil="tilbud@******.net"; $headers = "From: $franavn<$framail>"; if(! mail($sendtil, $emne, $indhold, $headers)) echo "Fejl: Beskeden blev ikke sendt"; else echo "Du høre fra mig"; } } ?> </p> </div> <div class="section contact"> <p> Du kan kontakte os via kontaktformularen til venstre<br><br><span>eller</span><br><br>Du kan skrive os en mail.<br><br>Tilbud:<br>Tilbud@Ringvig.net<br><br>Support:<br>Support@Ringvig.net </p> </div> </div> <div id="footer"> <div class="clearfix"> <div id="connect"> Like os på facebook<br><a href="https://www.facebook.com/****" target="_blank" class="facebook"></a> </div> <p> © 2013 Ringvig.net All Rights Reserved. </p> </div> </div> </body> </html>
<html> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <?php $id=$_GET['id']; switch($id){ case "Tilbud"; $str ="<input type='text' name='navn' value='Navn'> <input type='text' name='mail' value='E-mail'> <select size='1' name='valg'> <option selected> Vælg </option> <option>Løsning 1</option> <option>Løsning 2</option> <option>Andet</option></select> <textarea name='tekst'>Skriv kort om hvad siden skal handle om</textarea> <input type='submit' value='Send'>"; break; case "Support"; $str ="<input type='text' name='navn' value='Navn'> <input type='text' name='mail' value='E-mail'> <input type='text' name='fejl' value='Vedr'> <textarea name='tekst'>Skriv din besked her</textarea> <input type='submit' value='Send'>"; break; default: $str = "<input type='submit' value='Send'>"; break; } echo $str; ?> </html>