我是初学者,当涉及到JavaScript时,对我一无所知。我有一个用户填写的表单,我想将这些答案提交给javascript中的变量,然后调用一个函数来显示在不同页面上输入表单的所有数据。例如,表单在1.html上,用户按下提交按钮,重定向到2.html,提交的信息显示在这里。这里是我的形式:Javascript窗体变量
<form action="addaddresspage3.html" method="post" id="form" class="form">
<div id="form1">
<div class="row form-row form-bg">
<div class="container">
<div class="col-md-12 form-wrapper">
<form role="form">
<div class="form-content">
<legend class="hd-default">Billing Address</legend>
<div class="row">
<div class="form-group col-md-4 col-sm-6">
<label for="first-name">First Name(s)*:</label>
<input type="text" id="firstname" class="form-control" placeholder="First Name(s)" required="">
</div>
</div>
<div class="row">
<div class="form-group col-md-4 col-sm-6">
<label for="password">Surname*:</label>
<input type="text" id="surname" class="form-control" placeholder="Surname" required="">
</div>
</div>
<div class="col-md-12">
<div class="row">
<div class="form-group col-md-3 col-sm-3">
<label>Country of Home Address</label>
<select name="title" id="addresslist" class="form-control">
<option value="1">Select Address</option>
<option value="1">United Kingdom</option>
<option value="2">Saudi Arabia</option>
<option value="3">Iran</option>
<option value="4">Nigeria</option>
</select>
</div>
</div>
<div class="row">
<div class="form-group col-md-4 col-sm-6">
<label for="street_<cfoutput>#Add#</cfoutput>">House number and street:</label>
<input type="text" name="street_#Add#" validateat="onSubmit" validate="maxlength" required="yes" id="autocomplete" size="54" maxlength="120" message="Please enter owner #Peoplecount#'s mailing address." onFocus="geolocate()" placeholder="Please enter your house number and street">
<p>
<label for="city_<cfoutput>#Add#</cfoutput>">Town:</label>
<input type="text" name="city_#Add#" validateat="onSubmit" validate="maxlength" required="yes" id="locality" size="30" maxlength="50" message="Please enter owner #Peoplecount#'s mailing city." value="">
</p>
<label for="street_<cfoutput>#Add#</cfoutput>">Postcode:</label>
<input type="text" name="postal_#Add#" required="yes" id="postal_code" size="8" maxlength="12" message="Please enter owner #Peoplecount#'s mailing zip code." value="">
</div>
</div>
</div>
</div>
</div>
<input type="submit" id="continue" disabled="disabled" value="Add Address"/>
</div>
你写的JavaScript在哪里?请注意,*变量*不会将值传递到下一页,但可以将这些值存储在本地存储器中,或者将它们包含在下一页的查询字符串中。 – David
那么有没有办法让页面之间传递变量? – Alice
正如我所描述的,您可以存储或提交*值*。但是,作为内存概念的“变量”将不会在该变量的寿命范围之外提供。每种编程语言都是如此。 – David