benedictbutlin
Technical User
I'm not very knowledgeable with javascript.i'd found this code that allows me to add additional input fields to my form. works great but when i click the link to add fields the page scrolls goes back to the top and doesn't stay in it's same position. how would i modify the code to make the page stay where it is?
javascript...
here's the form input/ div
javascript...
Code:
<script type="[URL unfurl="true"]http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>[/URL]
<link rel="stylesheet" type="text/css" href="css/css.css" />
<script type="text/javascript">
var count = 0;
$(function(){
$('p#add_field').click(function(){
count += 1;
$('#container').append(
'<div id="field_holder">'
+ '<div id="field_name" <?PHP echo $form_lengthA; ?>>Parameter #' + count + '</div>'
+ '<div id="field_input" <?PHP echo $form_lengthB; ?>><input <?PHP echo $form_lengthB; ?> type="text" id="field_' + count + '" name="fields[]' + '" ></div>' );
+'</div>'
});
});
</script>
here's the form input/ div
Code:
echo'<div id="container">';
echo '<div id="field_holder">';
echo '<div id="field_name" '.$form_lengthA.'>(empty fields are ignored)</div>';
echo '<div id="field_input" '.$form_lengthB.'>';
echo'<p id="add_field"><a href="#"><span>+ more fields </span></a><br></p>';
echo'</div>';
echo'</div>';
echo'</div>';