M
markrenn
is there a way to get the index of an array aside from the values that
you passed from a form?
<form name="details">
<label for="fname">
first name:
<input type="text" name="name['firstname']" id="fname" />
</label>
<label for="mname">
middle name:
<input type="text" name="name['middlename']" id="mname" />
</label>
<label for="lname">
last name:
<input type="text" name="name['lastname']" id="lname" />
</label>
<label for="hnum">
home number:
<input type="text" name="num['homenumber']" id="hnum" />
</label>
<label for="mnum">
mobile number:
<input type="text" name="num['mobilenunber']" id="mnum" />
</label>
<label for="fnum">
fax number:
<input type="text" name="num['faxnumber']" id="fnum" />
</label>
<input type="button" name="showName"
onclick="display('details','name[]')" />
<input type="button" name="showNum" onclick="display('details',
'num[]')" />
</form>
so here is my script.(which doesnt really work right)
function display(the_form,the_element){
var elts = document.forms[the_form].elements[the_element];
var elts_cnt = (typeof(elts.length) != 'undefined')? elts.length : 0;
var param = '';
if (elts_cnt)
{
for (var i in elts)
{
param = param + i + "=" + elst + "&";
} // end for
param = param.substring(0,(param.length-1));
} // end if
alert(param);
}
i need to make the param like this
firstname=joe&middlename=smith&lastname=wilson&......
you passed from a form?
<form name="details">
<label for="fname">
first name:
<input type="text" name="name['firstname']" id="fname" />
</label>
<label for="mname">
middle name:
<input type="text" name="name['middlename']" id="mname" />
</label>
<label for="lname">
last name:
<input type="text" name="name['lastname']" id="lname" />
</label>
<label for="hnum">
home number:
<input type="text" name="num['homenumber']" id="hnum" />
</label>
<label for="mnum">
mobile number:
<input type="text" name="num['mobilenunber']" id="mnum" />
</label>
<label for="fnum">
fax number:
<input type="text" name="num['faxnumber']" id="fnum" />
</label>
<input type="button" name="showName"
onclick="display('details','name[]')" />
<input type="button" name="showNum" onclick="display('details',
'num[]')" />
</form>
so here is my script.(which doesnt really work right)
function display(the_form,the_element){
var elts = document.forms[the_form].elements[the_element];
var elts_cnt = (typeof(elts.length) != 'undefined')? elts.length : 0;
var param = '';
if (elts_cnt)
{
for (var i in elts)
{
param = param + i + "=" + elst + "&";
} // end for
param = param.substring(0,(param.length-1));
} // end if
alert(param);
}
i need to make the param like this
firstname=joe&middlename=smith&lastname=wilson&......