Do a select field which changes hidden input value?

I’m currently trying to build a expire url system but im stuck with an issue. What i’m trying yo achieve is when you for example select the “Clicks” option of the select field, it changes the hidden iput field below to click but if you slect minutes, hours, days it changes the input to period!

Thanks

<select id="period" name="period"> 
<option value="clicks" selected="">Clicks</option> 
<option value="minutes">Minutes</option> 
<option value="hours">Hours</option> 
<option value="days">Days</option>
</select>

<input id="linklimit" id="linklimit" name="linklimit" value="" type="hidden">
<select id="period" name="linklimit"> 
<option value="click" selected>Clicks</option> 
<option value=".">Minutes</option> 
<option value=".">Hours</option> 
<option value=".">Days</option>
</select>

(There is no discernable value in hiding the input value, when you already have a visible selector for said value.)

No i have a database and one row has period or clicks and thats how it determines if you are doing doing time or just number of clicks until expire. The select field you just changed should not change because that value data goes into another database row which is the duration period all i want is for jquery to look and see that when i select minutes = period so it dynamically changes the hidden input field but if i was to click the one with clicks then instead of period it puts click in the hidden field value box?

im sure thats possible im just unsure how to do it

Thanks

IMO, you’d do better with changing your form handling script to handle this, as it reduces points of failure.

BUT. Since you’re dead set on doing it this way.

<select id="period" name="period"> 
<option value="clicks" selected="">Clicks</option> 
<option value="minutes">Minutes</option> 
<option value="hours">Hours</option> 
<option value="days">Days</option>
</select>

<input id="linklimit" id="linklimit" name="linklimit" value="click" type="hidden">
<script>
$("#period").on('change', function () { $("#linklimit").val(($("#period").val() === "clicks") ? "click" : "." ) });
</script>

im sorry but do you understand what im trying to do? All i want to do is have it so that if you click on a certain select option it adds either click or period to the hidden input value

so if i click the first option with clicks then it puts click in the hidden select field but if i do minutes seconds or hours then it puts period

Thanks for you help so far and what was the jquery above supposed to do because nothing happened thanks very much

please ignore my last thing it works great thanks very much

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.