尝试使用图像将变量保存到MYSQL数据库表

时间:2012-04-13 00:52:27

标签: php javascript mysql forms

所以我不确定如何问这个...但我正在创建一个网站,您可以在其中点击六个天气图标中的一个,将您带到一个允许您输入姓名的页面以及与天气相关的故事,并将其发布在最后一页上,其他人讲述了相同类型的天气。我有一个表来设置保存名称和故事,但我不确定当用户点击其中一个图标时如何保存天气。

我的老师说要用javascript做一些事情并制作隐藏的表格或其他东西。如果这会有所帮助,那么继承该网站的链接。 http://www.tcnjart.com/christineaustin/whethertheweather/index.html

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>WhethertheWeather.</title>

<!--<link rel="stylesheet" type="text/css" href="demo/css/screen.css" media="all" />-->
    <script src="http://www.adrianpelletier.com/mint/?js" type="text/javascript">           
 </script>
    <script type="text/javascript" src="demo/scripts/jquery-1.3.2.min.js"></script>
    <script type="text/javascript" src="demo/scripts/jquery-ui-1.7.1.custom.min.js">      
 </script>
    <script type="text/javascript" src="demo/scripts/execute.js"></script>


 <script>
     function connect(){
var moveto= $.(#sel).attr("name");
$(#myweather).value=moveto;
myform.submit;

}

</script>

<link href="style.css" rel="stylesheet" type="text/css">
</head>

<body background="images/gradientsky.jpg"> 

 <div id="logo">

WhethertheWeather.

</div>

<div id="question">

Whats your favorite weather?

</div>

<div id="weather">

<ul id="nav-reflection">
<form name="myform" method="post" action="cloudy_name.php">
    <li class="button-color-1"><a href="javascript:connect();"id="sel"name"cloudy"       
 title="My fancy link"><img src="images/cloudybubble.png" width="211" height="180"align="left">  
</a></li>
<li class="button-color-1"><a href="sunny_name.php" title="My fancy link"><img               src="images/sunnybubble.png" width="211" height="180" align="left"></a></li>
<li class="button-color-2"><a href="snowy_name.php" title="My fancy link"><img src="images/snowbubble.png" width="211" height="180" align="left"></a></li>
<li class="button-color-1"><a href="snowy_name.php" title="My fancy link"><img src="images/rainbubble.png" width="211" height="180" align="left"></a></li>
<li class="button-color-1"><a href="mixy_name.php" title="My fancy link"><img src="images/mixbubble.png" width="211" height="180" align="left"></a></li>
<li class="button-color-1"><a href="windy_name.php" title="My fancy link"<imgsrc="images/windybubble.png" width="211" height="180" align="left"></a></li>

<input type="hidden" name="weather" value="none" id="myweather">
</form>
</ul>
</div>

</body>
</html>

1 个答案:

答案 0 :(得分:0)

嗯,首先,这个功课的目的是让你自己弄清楚如何做到这一点,虽然我想那些有点就是这个。

设置图像的onclick属性设置隐藏表单元素的值。这应该足以让你谷歌并得到一个正确的答案。

<img src=foo onclick="javascript_code_goes_here">

<input type=hidden name='weather' id='weather' value=''>