mercredi 23 septembre 2015

Using if / else to define blank var

I have searched a bit, and either my phrasing is off, or this hasn't been asked this way before:

I am using an input box via html to allow a user to input a version number (of a game )

<label>Version Number</label>
<input size="19" maxlength="19" class="version" type="text" placeholder="Use only if updating version" />
<br>

I have it defined here in my javascript:

  values[5] = $('.version').val();

I then go further to try and make the variable define a different var:

if (values[5] == '') {
    var updatenumber = 'a ' + type['en'][values[2]];
    var frupdatenumber = frlaunchweird;
    var deupdatenumber = type['de'][values[2]];
}
else { 
    var updatenumber = 'an ' + type['en'][values[2]];
    var frupdatenumber = ' ' + values[5];
    var deupdatenumber = ' ' + ' ' + values[5];
}

The idea is that I want the code to put an article "an" (plus a different value) if the number box has anything in it, and the article "a" (plus a different value) when it is left blank.

I have the complete version via a codepen here: http://ift.tt/1NTr9iT

Question: Why doesn't this want to work? Is it a formatting issue?

I am getting no error message, and the intended result is that I get neither article to appear as intended.

I get no acknowledgement that the vars are being redefined in the table cells I have defined here:

 var en_forum = 'The servers will come down for ' + updatenumber + ' on ' + months['en'][values[0]] + ' ' + values[1] + ', at ' + values[3] + ':' + values[7] + ' GMT/ ' + edt + ':' + values[7] + ampm +' EDT/ ' + pdt + ':' + values[7] + pampm + ' PDT.([url="';

Instead, I just get the [en][values[2]] and not the preceding 'an ' or 'a '. –

Thank you all for the help!

Aucun commentaire:

Enregistrer un commentaire