I create a D3 bar chart that where the input data is from a range of generation inside a json file. I want to create a form with two text fields where i can insert the range and then update the chart.
The first form update the ST variabll and update the page, that is OK. The next step is update the range os the charts but without refresh the page, so the form1 should be "static". I try to repeat the same procedure for the myfor2 and the variables are not updated.
<form name="myform1" action="#" method="get" style="position: relative; top:10px;width:300px;margin-left:-70px;" >
Input the St number<br />
<input type="text" name="StNumber" id="StNumber" value="9" /><br />
<input type="submit" value="Set Value" /><br />
</form>
<form name="myform2" action="#" method="get" style="position: relative; top:10px">
Input the start generation<br />
<input type="text" name="GenStart" id="GenStart" value="2000" /><br />
Input the final generation<br />
<input type="text" name="GenFinal" id="GenFinal" value="2400" /><br />
<input type="submit" value="Set Value" /><br />
</form>
Function that update the form one, that is ok:
function setValue(){
var url=window.location+'';
if(url.indexOf('?StNumber=')){
var StNumber=parseInt(url.split('?StNumber=')['1']);
if(StNumber>0 && isNaN(StNumber)==false){
document.getElementById('StNumber').value = StNumber;
StID = String(StNumber);
}
}else{
StID = "9";
}
}
setValue();
Any sugestion!
Regards
http://jsfiddle.net/bnACW/425/
I need to update the javascript variables independently. in myform1 I update the StID and set the value the variable are saved; Then: in the myfor2 I update the endGen or StartGen or even the two at the same time ad set and the variablesare updated as the chart that need this two variables.