populate hidden field from PHP database
Posted: Tue Jul 26, 2011 4:48 pm
Is there a way to call a PHP database within a *.html page and populate the answer to a hidden field? For example: SQL DB has 2 fields ID and SEGMENT,
ID SEGMENT
1 A
2 B
3 C
4 D
I have a form:
<form action="Untitled-2.php" method="post" name="form1" id="form">
<input type="radio" name="ID" value="4" />
4</label>
<label>
<input type="radio" name="ID" value="3" />
3</label>
<label>
<input type="radio" name="ID" value="2" />
2</label>
<label>
<input type="radio" name="ID" value="1" />
1</label>
<input name="segment" id="segment" type="hidden" />
I want to be able to have a button onclick() go out the the php server collect which Segment it is and populate the hidden text field "segment" then submit all on the same HTML page? Can this be done using AJAX, if so do you have the code?
ID SEGMENT
1 A
2 B
3 C
4 D
I have a form:
<form action="Untitled-2.php" method="post" name="form1" id="form">
<input type="radio" name="ID" value="4" />
4</label>
<label>
<input type="radio" name="ID" value="3" />
3</label>
<label>
<input type="radio" name="ID" value="2" />
2</label>
<label>
<input type="radio" name="ID" value="1" />
1</label>
<input name="segment" id="segment" type="hidden" />
I want to be able to have a button onclick() go out the the php server collect which Segment it is and populate the hidden text field "segment" then submit all on the same HTML page? Can this be done using AJAX, if so do you have the code?