Click here to Skip to main content
15,888,341 members
Home / Discussions / JavaScript
   

JavaScript

 
Questionangular-cli chrome extension bootstrap from many .html Pin
JulioGold19-Feb-17 8:29
JulioGold19-Feb-17 8:29 
Questionremoving duplicates from array in order to use regex to find match. returning null Pin
Member 1299542016-Feb-17 16:26
Member 1299542016-Feb-17 16:26 
AnswerRe: removing duplicates from array in order to use regex to find match. returning null Pin
Nathan Minier17-Feb-17 1:31
professionalNathan Minier17-Feb-17 1:31 
QuestionAJAX request for photos Pin
Member 1300611016-Feb-17 11:06
Member 1300611016-Feb-17 11:06 
QuestionDynamically add row by DIV(SOLVED) Pin
samflex16-Feb-17 5:46
samflex16-Feb-17 5:46 
AnswerRe: Dynamically add row by DIV Pin
Richard Deeming16-Feb-17 8:40
mveRichard Deeming16-Feb-17 8:40 
GeneralRe: Dynamically add row by DIV Pin
samflex16-Feb-17 9:05
samflex16-Feb-17 9:05 
GeneralRe: Dynamically add row by DIV Pin
Richard Deeming16-Feb-17 9:30
mveRichard Deeming16-Feb-17 9:30 
The example I posted was using Handlebars.js[^] - you just need to add a reference to the script file:
<script src="https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/4.0.6/handlebars.min.js" integrity="sha256-1O3BtOwnPyyRzOszK6P+gqaRoXHV6JXj8HkjZmPYhCI=" crossorigin="anonymous"></script>

In the template, I've given the fields sequential names, so you'll get sourcename1, sourcename2, etc. Obviously, if the user removes a row, you could get a gap in the sequence. You might want to add a hidden field within each row's <div> with a fixed name, which would then give you the list of IDs to look for in your PHP code:
HTML
<script id="row-template" type="text/x-handlebars-template">
<div>
    <input type="hidden" name="rowIDs" value="{{rowNumber}}" />
    ...
</div>
</script>

<div id="addrow">
    <div>
        <input type="hidden" name="rowIDs" value="1" />
        ...
    </div>
</div>

PHP
$rowIDs = $_POST['rowIDs'];
foreach ($rowIDs as $id) {
    $sourcename = $_POST['sourcename' . $id];
    $sourceaddress = $_POST['sourceaddress' . $id];
    $income = $_POST['income' . $id];
    ...
}




"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer


GeneralRe: Dynamically add row by DIV Pin
samflex16-Feb-17 9:39
samflex16-Feb-17 9:39 
GeneralRe: Dynamically add row by DIV Pin
Richard Deeming16-Feb-17 10:12
mveRichard Deeming16-Feb-17 10:12 
GeneralRe: Dynamically add row by DIV Pin
samflex16-Feb-17 10:27
samflex16-Feb-17 10:27 
GeneralRe: Dynamically add row by DIV Pin
samflex16-Feb-17 10:52
samflex16-Feb-17 10:52 
GeneralRe: Dynamically add row by DIV Pin
Richard Deeming17-Feb-17 2:07
mveRichard Deeming17-Feb-17 2:07 
GeneralRe: Dynamically add row by DIV Pin
samflex17-Feb-17 2:53
samflex17-Feb-17 2:53 
QuestionInheriting a Javascript Prototype for Web Usercontrol Pin
HemeshSoni13-Feb-17 5:27
HemeshSoni13-Feb-17 5:27 
AnswerRe: Inheriting a Javascript Prototype for Web Usercontrol Pin
Richard Deeming13-Feb-17 8:06
mveRichard Deeming13-Feb-17 8:06 
GeneralRe: Inheriting a Javascript Prototype for Web Usercontrol Pin
HemeshSoni13-Feb-17 17:18
HemeshSoni13-Feb-17 17:18 
AnswerRe: Inheriting a Javascript Prototype for Web Usercontrol Pin
HemeshSoni13-Feb-17 17:25
HemeshSoni13-Feb-17 17:25 
Questionmvc app with angular not working in IIS on 80 port Pin
Member 1103130413-Feb-17 0:17
Member 1103130413-Feb-17 0:17 
AnswerRe: mvc app with angular not working in IIS on 80 port Pin
Nathan Minier13-Feb-17 0:54
professionalNathan Minier13-Feb-17 0:54 
GeneralRe: mvc app with angular not working in IIS on 80 port Pin
Member 1103130413-Feb-17 1:04
Member 1103130413-Feb-17 1:04 
GeneralRe: mvc app with angular not working in IIS on 80 port Pin
Nathan Minier13-Feb-17 1:27
professionalNathan Minier13-Feb-17 1:27 
GeneralRe: mvc app with angular not working in IIS on 80 port Pin
Member 1103130413-Feb-17 2:02
Member 1103130413-Feb-17 2:02 
Questionlooping through an array that has value based on a dice roll. Need to properly calculate the rolls. Pin
Member 1299542011-Feb-17 9:25
Member 1299542011-Feb-17 9:25 
AnswerRe: looping through an array that has value based on a dice roll. Need to properly calculate the rolls. Pin
Richard MacCutchan11-Feb-17 20:45
mveRichard MacCutchan11-Feb-17 20:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.