PDA

View Full Version : سوال: کمک برای یه سوال مهم از javascript . فوری فوری



samajoon
دوشنبه 13 دی 1389, 16:34 عصر
:بوس:
سلام بچه ها . من یه سوال داشتم . لطفا زود زود جواب بدین

من یه فرم درست کردم تو front page که شامل :

- Education - name - Email - Gender - Resident - Favorits هست برای دریافت اطلاعات از کاربر که البته همه بلدن
حالا وقتی کاربر دکمه submit رو می زنه .... می خوام بره یه صفحه دیگه که باز تو همون front page درست کردم

و اطلاعاتی رو که کاربر وارد کرده نشون بده به این صورت :

hello Mr & Mrs Name
your Education is PHD & TS & BS
your are live in Iran & out of iran
your favorite is cinema & sport & Internet
Contact

فهمیدین ؟؟؟؟ :تشویق:

یعنی اگه تو Gender انتخاب کاربر Male بود بنویسه hello Mr Name که name هم همون اسم طرف باید باشه
یا اگه Resident رو ایران انتخاب کرد بنویسه your live in iran و به همین ترتیب .
اون contact هم می خوام لینک ایمیلی باشه که وارد می کنه ....

در ضمن من از text box برای name , Email
از option button برای gender , Resident
از drop down box برای education
از chech box برای favorite استفاده کردم . کمکککککککک

من نمی دونم باید از چه تابعی استفاده کنم .. اصلا تابع توی صفحه فرم هست یا صفحه دوم که اطلاعات رو نمایش می ده ؟؟؟؟؟ یکی کمک کنه زووووووووووووود خواهش می کنم ...
:افسرده: بهم ایمیل بزنید خواهش می کنم : samajoon.n@gmail.com

Mr FTHEL
دوشنبه 13 دی 1389, 21:51 عصر
اگر ممکن هست کد رو بزارید تا اوکی بشه:چشمک:

samajoon
سه شنبه 14 دی 1389, 11:45 صبح
کدهای من با html و javascript با فرانت پیج هستن .
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
</head>
<body style="text-align: center" background="418425161_colorful-wallpaper(4).jpg">

<table border="0" width="53%" height="417">
<tr>
<td width="119"><font size="5">Name :</font></td>
<td width="148"><font size="5">
<input type="text" name="Name" size="20"></font></td>
<td>&nbsp;</td>
</tr>
<tr>
<td width="119"><font size="5">Email :</font></td>
<td width="148"><font size="5">
<input type="text" name="Email" size="20"></font></td>
<td>&nbsp;</td>
</tr>
<tr>
<td width="119"><font size="5">Gender :</font></td>
<td width="148"><font size="5">
<input type="radio" value="V1" name="Gender">Male </font></td>
<td><font size="5"><input type="radio" name="Gender" value="V2">Female</font></td>
</tr>
<tr>
<td width="119"><font size="5">Resident :</font></td>
<td width="148"><font size="5">
<input type="radio" name="Resident" value="V3">Iran</font></td>
<td><font size="5"><input type="radio" name="Resident" value="V4">Out-of-Iran</font></td>
</tr>
<tr>
<td width="119"><font size="5">Education :</font></td>
<td width="148"><font size="5">
<select size="1" name="Education" style="font-family: Times New Roman; font-size: 14pt">
<option>Diploma</option>
<option>TS</option>
<option>BS</option>
<option>MS</option>
<option>PHD</option>
</select></font></td>
<td>&nbsp;</td>
</tr>
<tr>
<td width="119"><font size="5">Favorites :</font></td>
<td width="148"><font size="5">
<input type="checkbox" name="Cinema" value="ON">Cinema</font></td>
<td><font size="5"><input type="checkbox" name="Sport" value="ON">Sport</font></td>
</tr>
<tr>
<td width="119">&nbsp;</td>
<td width="148"><font size="5">
<input type="checkbox" name="Sleep" value="ON">Sleep</font></td>
<td><font size="5">
<input type="checkbox" name="Internet" value="ON">Internet</font></td>
</tr>
</table>
<p>
<input type="submit" value="SHOW" name="B1" style="font-family: Times New Roman; font-size: 14pt; color: #000000; float: right; border: 3px ridge #000000; background-color: #C4E8C1"></p>
</form>
</body>
</html>

hossin.esm
سه شنبه 14 دی 1389, 16:33 عصر
من دو تا از فیلد ها نوشتم بقیه را میتونی خودت کامل کنی.
در فایل اولی <form action="2.html" > را اضافه کردم که اطلاعات را به فایل دوم یعنی 2.html می فرستد.


<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
</head>
<body style="text-align: center" background="418425161_colorful-wallpaper(4).jpg">
<form action="2.html" >
<table border="0" width="53%" height="417">
<tr>
<td width="119"><font size="5">Name :</font></td>
<td width="148"><font size="5">
<input type="text" name="Name" size="20"></font></td>
<td>&nbsp;</td>
</tr>
<tr>
<td width="119"><font size="5">Email :</font></td>
<td width="148"><font size="5">
<input type="text" name="Email" size="20"></font></td>
<td>&nbsp;</td>
</tr>
<tr>
<td width="119"><font size="5">Gender :</font></td>
<td width="148"><font size="5">
<input type="radio" value="V1" name="Gender">Male </font></td>
<td><font size="5"><input type="radio" name="Gender" value="V2">Female</font></td>
</tr>
<tr>
<td width="119"><font size="5">Resident :</font></td>
<td width="148"><font size="5">
<input type="radio" name="Resident" value="V3">Iran</font></td>
<td><font size="5"><input type="radio" name="Resident" value="V4">Out-of-Iran</font></td>
</tr>
<tr>
<td width="119"><font size="5">Education :</font></td>
<td width="148"><font size="5">
<select size="1" name="Education" style="font-family: Times New Roman; font-size: 14pt">
<option>Diploma</option>
<option>TS</option>
<option>BS</option>
<option>MS</option>
<option>PHD</option>
</select></font></td>
<td>&nbsp;</td>
</tr>
<tr>
<td width="119"><font size="5">Favorites :</font></td>
<td width="148"><font size="5">
<input type="checkbox" name="Cinema" value="ON">Cinema</font></td>
<td><font size="5"><input type="checkbox" name="Sport" value="ON">Sport</font></td>
</tr>
<tr>
<td width="119">&nbsp;</td>
<td width="148"><font size="5">
<input type="checkbox" name="Sleep" value="ON">Sleep</font></td>
<td><font size="5">
<input type="checkbox" name="Internet" value="ON">Internet</font></td>
</tr>
</table>
<p>
<input type="submit" value="SHOW" name="B1" style="font-family: Times New Roman; font-size: 14pt; color: #000000; float: right; border: 3px ridge #000000; background-color: #C4E8C1"></p>
</form>
</body>
</html>



2.html

<html>
<head>
<!-- head stuff -->
<script type="text/javascript">
<!-- hide from old browsers
function getValue(varname)
{
// First, we load the URL into a variable
var url = window.location.href;
// Next, split the url by the ?
var qparts = url.split("?");
// Check that there is a querystring, return "" if not
if (qparts.length == 0)
{
return "";
}
// Then find the querystring, everything after the ?
var query = qparts[1];
// Split the query string into variables (separates by &s)
var vars = query.split("&");
// Initialize the value with "" as default
var value = "";
// Iterate through vars, checking each one for varname
for (i=0;i<vars.length;i++)
{
// Split the variable by =, which splits name and value
var parts = vars[i].split("=");

// Check if the correct variable
if (parts[0] == varname)
{
// Load value into variable
value = parts[1];
// End the loop
break;
}
}

// Convert escape code
value = unescape(value);
// Convert "+"s to " "s
value.replace(/\+/g," ");
// Return the value
return value;
}
// end hide -->
</script>
</head>
<body>
<script type="text/javascript">
var Name = getValue("Name");
var Gender=getValue("Gender");
var Education=getValue("Education");
document.write("Hello "+ Gender+" "+Name +"<br \>");
document.write("your Education "+ Education+"<br \>");

</script>
</body>
</html>